|
1 | 1 | package com.aerospike.mapper.tools;
|
2 | 2 |
|
3 |
| -import com.aerospike.client.*; |
| 3 | +import java.io.File; |
| 4 | +import java.io.IOException; |
| 5 | +import java.io.InputStream; |
| 6 | +import java.lang.reflect.Array; |
| 7 | +import java.util.ArrayList; |
| 8 | +import java.util.List; |
| 9 | +import java.util.concurrent.atomic.AtomicBoolean; |
| 10 | +import java.util.function.Function; |
| 11 | + |
| 12 | +import javax.validation.constraints.NotNull; |
| 13 | + |
| 14 | +import org.apache.commons.lang3.StringUtils; |
| 15 | + |
| 16 | +import com.aerospike.client.AerospikeException; |
4 | 17 | import com.aerospike.client.AerospikeException.ScanTerminated;
|
| 18 | +import com.aerospike.client.Bin; |
| 19 | +import com.aerospike.client.IAerospikeClient; |
| 20 | +import com.aerospike.client.Key; |
| 21 | +import com.aerospike.client.Log; |
| 22 | +import com.aerospike.client.Operation; |
5 | 23 | import com.aerospike.client.Record;
|
| 24 | +import com.aerospike.client.Value; |
6 | 25 | import com.aerospike.client.policy.BatchPolicy;
|
7 | 26 | import com.aerospike.client.policy.Policy;
|
8 | 27 | import com.aerospike.client.policy.QueryPolicy;
|
|
22 | 41 | import com.fasterxml.jackson.core.JsonProcessingException;
|
23 | 42 | import com.fasterxml.jackson.databind.ObjectMapper;
|
24 | 43 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
25 |
| -import org.apache.commons.lang3.StringUtils; |
26 |
| - |
27 |
| -import javax.validation.constraints.NotNull; |
28 |
| -import java.io.File; |
29 |
| -import java.io.IOException; |
30 |
| -import java.io.InputStream; |
31 |
| -import java.lang.reflect.Array; |
32 |
| -import java.util.ArrayList; |
33 |
| -import java.util.List; |
34 |
| -import java.util.concurrent.atomic.AtomicBoolean; |
35 |
| -import java.util.function.Function; |
36 | 44 |
|
37 | 45 | public class AeroMapper implements IAeroMapper {
|
38 | 46 |
|
@@ -216,22 +224,25 @@ private <T> void save(WritePolicy writePolicy, @NotNull T object, RecordExistsAc
|
216 | 224 | if (recordExistsAction != null) {
|
217 | 225 | writePolicy.recordExistsAction = recordExistsAction;
|
218 | 226 | }
|
| 227 | + |
| 228 | + // #132 -- Ensure that if an overriding TTL / sendkey is passed in the policy it is NOT overwritten. Hence |
| 229 | + // only if the policy is null do we override these settings. |
| 230 | + Integer ttl = entry.getTtl(); |
| 231 | + Boolean sendKey = entry.getSendKey(); |
| 232 | + |
| 233 | + if (ttl != null) { |
| 234 | + writePolicy.expiration = ttl; |
| 235 | + } |
| 236 | + if (sendKey != null) { |
| 237 | + writePolicy.sendKey = sendKey; |
| 238 | + } |
219 | 239 | }
|
220 | 240 |
|
221 | 241 | String set = entry.getSetName();
|
222 | 242 | if ("".equals(set)) {
|
223 | 243 | // Use the null set
|
224 | 244 | set = null;
|
225 | 245 | }
|
226 |
| - Integer ttl = entry.getTtl(); |
227 |
| - Boolean sendKey = entry.getSendKey(); |
228 |
| - |
229 |
| - if (ttl != null) { |
230 |
| - writePolicy.expiration = ttl; |
231 |
| - } |
232 |
| - if (sendKey != null) { |
233 |
| - writePolicy.sendKey = sendKey; |
234 |
| - } |
235 | 246 | Key key = new Key(entry.getNamespace(), set, Value.get(entry.getKey(object)));
|
236 | 247 |
|
237 | 248 | Bin[] bins = entry.getBins(object, writePolicy.recordExistsAction != RecordExistsAction.REPLACE, binNames);
|
|
0 commit comments