@Override public Object setAttribute(String name, Object value) { if (value == null) { return this.removeAttribute(name); } if (this.properties.isMarshalling() && !this.marshallability.isMarshallable(value)) { throw new IllegalArgumentException(new NotSerializableException(value.getClass().getName())); } Object old = this.attributes.put(name, value); this.mutator.mutate(); if (this.mutations != null) { this.mutations.remove(name); } return old; }
public void testNonSerializable() throws Exception { try { marshaller.objectToByteBuffer(new Object()); } catch (NotSerializableException e) { log.info("Log exception for output format verification", e); TraceInformation inf = (TraceInformation) e.getCause(); if (inf != null) { assert inf.toString().contains("in object java.lang.Object@"); } } }
public void testNestedNonSerializable() throws Exception { PutKeyValueCommand cmd = new PutKeyValueCommand( "k", new Object(), false, null, new EmbeddedMetadata.Builder().build(), 0, EnumUtil.EMPTY_BIT_SET, CommandInvocationId.generateId(null)); try { marshaller.objectToByteBuffer(cmd); } catch (NotSerializableException e) { log.info("Log exception for output format verification", e); TraceInformation inf = (TraceInformation) e.getCause(); if (inf != null) { assert inf.toString().contains("in object java.lang.Object@"); } } }
@Override public Object setAttribute(String name, Object attribute) { if (attribute == null) { return this.removeAttribute(name); } if (this.properties.isMarshalling() && !this.marshaller.isMarshallable(attribute)) { throw new IllegalArgumentException(new NotSerializableException(attribute.getClass().getName())); } V value = this.marshaller.write(attribute); UUID attributeId = this.names.get(name); if (attributeId == null) { UUID newAttributeId = UUID.randomUUID(); this.setNames(this.namesCache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS).compute(this.createKey(), this.properties.isTransactional() ? new CopyOnWriteMapPutFunction<>(name, newAttributeId) : new ConcurrentMapPutFunction<>(name, newAttributeId))); attributeId = this.names.get(name); } Object result = this.read(name, this.attributeCache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS).put(this.createKey(attributeId), value)); this.mutations.remove(name); return result; }