use of java.io.NotSerializableException in project dubbo by alibaba.
the class AbstractSerializationPersionFailTest method test_StringPersonMap.
@Test
public void test_StringPersonMap() throws Exception {
Map<String, Person> args = new HashMap<String, Person>();
args.put("1", new Person());
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
}
}
use of java.io.NotSerializableException in project midpoint by Evolveum.
the class PropertyComplexValueFilterType method copyOf.
/**
* Creates and returns a deep copy of a given {@code Serializable}.
*
* @param serializable
* The instance to copy or {@code null}.
* @return
* A deep copy of {@code serializable} or {@code null} if {@code serializable} is {@code null}.
*/
private static Serializable copyOf(final Serializable serializable) {
// CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
if (serializable != null) {
try {
final ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
final ObjectOutputStream out = new ObjectOutputStream(byteArrayOutput);
out.writeObject(serializable);
out.close();
final ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(byteArrayOutput.toByteArray());
final ObjectInputStream in = new ObjectInputStream(byteArrayInput);
final Serializable copy = ((Serializable) in.readObject());
in.close();
return copy;
} catch (SecurityException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (ClassNotFoundException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (InvalidClassException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (NotSerializableException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (StreamCorruptedException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (OptionalDataException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (IOException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
}
}
return null;
}
use of java.io.NotSerializableException in project midpoint by Evolveum.
the class QueryType method copyOf.
/**
* Creates and returns a deep copy of a given {@code Serializable}.
*
* @param serializable
* The instance to copy or {@code null}.
* @return
* A deep copy of {@code serializable} or {@code null} if {@code serializable} is {@code null}.
*/
private static Serializable copyOf(final Serializable serializable) {
// CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000
if (serializable != null) {
try {
final ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
final ObjectOutputStream out = new ObjectOutputStream(byteArrayOutput);
out.writeObject(serializable);
out.close();
final ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(byteArrayOutput.toByteArray());
final ObjectInputStream in = new ObjectInputStream(byteArrayInput);
final Serializable copy = ((Serializable) in.readObject());
in.close();
return copy;
} catch (SecurityException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (ClassNotFoundException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (InvalidClassException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (NotSerializableException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (StreamCorruptedException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (OptionalDataException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
} catch (IOException e) {
throw ((AssertionError) new AssertionError((("Unexpected instance during copying object '" + serializable) + "'.")).initCause(e));
}
}
return null;
}
use of java.io.NotSerializableException in project geode by apache.
the class DistributionManager method sendMessage.
/**
* @return recipients who did not receive the message
* @throws NotSerializableException If <codE>message</code> cannot be serialized
*/
Set sendMessage(DistributionMessage message) throws NotSerializableException {
Set result = null;
try {
// Verify we're not too far into the shutdown
stopper.checkCancelInProgress(null);
// avoid race condition during startup
waitUntilReadyToSendMsgs(message);
result = sendOutgoing(message);
} catch (NotSerializableException ex) {
// serialization error in user data
throw ex;
} catch (ToDataException ex) {
// serialization error in user data
throw ex;
} catch (ReenteredConnectException ex) {
// Recursively tried to get the same connection
throw ex;
} catch (CancelException ex) {
// bug 37194, shutdown conditions
throw ex;
} catch (InvalidDeltaException ide) {
logger.info(LocalizedMessage.create(LocalizedStrings.DistributionManager_CAUGHT_EXCEPTION_WHILE_SENDING_DELTA), ide.getCause());
throw (RuntimeException) ide.getCause();
} catch (Exception ex) {
DistributionManager.this.exceptionInThreads = true;
String receiver = "NULL";
if (message != null) {
receiver = message.getRecipientsDescription();
}
logger.fatal(LocalizedMessage.create(LocalizedStrings.DistributionManager_WHILE_PUSHING_MESSAGE_0_TO_1, new Object[] { message, receiver }), ex);
if (message == null || message.forAll())
return null;
result = new HashSet();
for (int i = 0; i < message.getRecipients().length; i++) result.add(message.getRecipients()[i]);
return result;
/*
* if (ex instanceof org.apache.geode.GemFireIpcResourceException) { return; }
*/
}
return result;
}
use of java.io.NotSerializableException in project geode by apache.
the class FunctionStreamingReplyMessage method fromData.
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
super.fromData(in);
this.msgNum = in.readInt();
this.lastMsg = in.readBoolean();
this.processorId = in.readInt();
try {
this.result = DataSerializer.readObject(in);
} catch (Exception e) {
// bug fix 40670
// Seems odd to throw a NonSerializableEx when it has already been
// serialized and we are failing because we can't deserialize.
NotSerializableException ioEx = new NotSerializableException();
ioEx.initCause(e);
throw ioEx;
}
}
Aggregations