use of org.apache.commons.lang.SerializationException in project geode by apache.
the class IntegratedSecurityService method postProcess.
public Object postProcess(Object principal, String regionPath, Object key, Object value, boolean valueIsSerialized) {
if (!needPostProcess())
return value;
if (principal == null) {
Subject subject = getSubject();
if (subject == null)
return value;
principal = (Serializable) subject.getPrincipal();
}
String regionName = StringUtils.stripStart(regionPath, "/");
Object newValue = null;
// it to the callback.
if (valueIsSerialized && value instanceof byte[]) {
try {
Object oldObj = EntryEventImpl.deserialize((byte[]) value);
Object newObj = postProcessor.processRegionValue(principal, regionName, key, oldObj);
newValue = BlobHelper.serializeToBlob(newObj);
} catch (IOException | SerializationException e) {
throw new GemFireIOException("Exception de/serializing entry value", e);
}
} else {
newValue = postProcessor.processRegionValue(principal, regionName, key, value);
}
return newValue;
}
use of org.apache.commons.lang.SerializationException in project geode by apache.
the class JGroupsMessengerJUnitTest method testSerializationError.
@Test
public void testSerializationError() throws Exception {
for (int i = 0; i < 2; i++) {
boolean enableMcast = (i == 1);
initMocks(enableMcast);
InternalDistributedMember mbr = createAddress(8888);
DistributedCacheOperation.CacheOperationMessage msg = mock(DistributedCacheOperation.CacheOperationMessage.class);
when(msg.getRecipients()).thenReturn(new InternalDistributedMember[] { mbr });
when(msg.getMulticast()).thenReturn(enableMcast);
if (!enableMcast) {
// for non-mcast we send a message with a reply-processor
when(msg.getProcessorId()).thenReturn(1234);
} else {
// for mcast we send a direct-ack message and expect the messenger
// to register it
stub(msg.isDirectAck()).toReturn(true);
}
when(msg.getDSFID()).thenReturn((int) DataSerializableFixedID.PUT_ALL_MESSAGE);
// for code coverage we need to test with both a SerializationException and
// an IOException. The former is wrapped in a GemfireIOException while the
// latter is not
doThrow(new SerializationException()).when(msg).toData(any(DataOutput.class));
try {
messenger.send(msg);
fail("expected a failure");
} catch (GemFireIOException e) {
// success
}
if (enableMcast) {
verify(msg, atLeastOnce()).registerProcessor();
}
doThrow(new IOException()).when(msg).toData(any(DataOutput.class));
try {
messenger.send(msg);
fail("expected a failure");
} catch (GemFireIOException e) {
// success
}
}
}
Aggregations