Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ISPN-5494 Node replies with NullPointerException during shutdown

Replace the exception with a CacheNotFoundResponse
  • Loading branch information...
commit 2372aa3fc98cac5ca703ae3047ade4f6e12ff982 1 parent 0323db1
@danberindei danberindei authored anistor committed
View
7 commons/src/main/java/org/infinispan/commons/marshall/jboss/AbstractJBossMarshaller.java
@@ -3,17 +3,16 @@
import org.infinispan.commons.io.ByteBuffer;
import org.infinispan.commons.io.ByteBufferImpl;
import org.infinispan.commons.io.ExposedByteArrayOutputStream;
-import org.infinispan.commons.logging.BasicLogFactory;
+import org.infinispan.commons.logging.Log;
+import org.infinispan.commons.logging.LogFactory;
import org.infinispan.commons.marshall.AbstractMarshaller;
import org.infinispan.commons.marshall.StreamingMarshaller;
import org.infinispan.commons.util.concurrent.ConcurrentWeakKeyHashMap;
-import org.jboss.logging.BasicLogger;
import org.jboss.marshalling.ExceptionListener;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.marshalling.TraceInformation;
import org.jboss.marshalling.Unmarshaller;
-import org.jboss.marshalling.reflect.SunReflectiveCreator;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -38,7 +37,7 @@
*/
public abstract class AbstractJBossMarshaller extends AbstractMarshaller implements StreamingMarshaller {
- protected static final BasicLogger log = BasicLogFactory.getLog(AbstractJBossMarshaller.class);
+ protected static final Log log = LogFactory.getLog(AbstractJBossMarshaller.class);
protected static final boolean trace = log.isTraceEnabled();
protected static final JBossMarshallerFactory factory = new JBossMarshallerFactory();
protected static final int DEF_INSTANCE_COUNT = 16;
View
7 core/src/main/java/org/infinispan/marshall/core/JBossMarshaller.java
@@ -2,6 +2,7 @@
import java.io.IOException;
+import org.infinispan.IllegalLifecycleStateException;
import org.infinispan.commons.marshall.SerializeWith;
import org.infinispan.commons.marshall.StreamingMarshaller;
import org.infinispan.commons.marshall.jboss.AbstractJBossMarshaller;
@@ -140,7 +141,11 @@ public void clear() {
@Override
public Writer getObjectWriter(Object o) throws IOException {
- return externalizerTable.getObjectWriter(o);
+ ExternalizerTable table = this.externalizerTable;
+ if (table == null) {
+ throw new IllegalLifecycleStateException("Cache marshaller has been stopped");
+ }
+ return table.getObjectWriter(o);
}
@Override
View
6 core/src/main/java/org/infinispan/remoting/transport/AbstractTransport.java
@@ -68,7 +68,11 @@ protected final boolean parseResponseAndAddToResponseList(Object responseObject,
throw new CacheException("Remote (" + sender + ") failed unexpectedly", exception);
}
- if (checkResponse(responseObject, sender)) responseListToAddTo.put(sender, (Response) responseObject);
+ if (checkResponse(responseObject, sender)) {
+ responseListToAddTo.put(sender, (Response) responseObject);
+ } else if (!ignoreLeavers && responseObject instanceof CacheNotFoundResponse) {
+ throw new SuspectException("Cache is stopping on node " + sender, sender);
+ }
} else if (wasSuspected) {
if (!ignoreLeavers) {
throw new SuspectException("Suspected member: " + sender, sender);
View
8 core/src/main/java/org/infinispan/remoting/transport/jgroups/CommandAwareRpcDispatcher.java
@@ -16,6 +16,7 @@
import java.util.concurrent.Future;
import net.jcip.annotations.GuardedBy;
+import org.infinispan.IllegalLifecycleStateException;
import org.infinispan.commands.FlagAffectedCommand;
import org.infinispan.commands.ReplicableCommand;
import org.infinispan.commons.CacheException;
@@ -295,7 +296,8 @@ public void handle(Message req, org.jgroups.blocks.Response response) throws Exc
ReplicableCommand cmd = null;
try {
cmd = (ReplicableCommand) req_marshaller.objectFromBuffer(req.getRawBuffer(), req.getOffset(), req.getLength());
- if (cmd == null) throw new NullPointerException("Unable to execute a null command! Message was " + req);
+ if (cmd == null)
+ throw new NullPointerException("Unable to execute a null command! Message was " + req);
if (req.getSrc() instanceof SiteAddress) {
executeCommandFromRemoteSite(cmd, req, response);
} else {
@@ -304,6 +306,10 @@ public void handle(Message req, org.jgroups.blocks.Response response) throws Exc
} catch (InterruptedException e) {
log.shutdownHandlingCommand(cmd);
reply(response, new ExceptionResponse(new CacheException("Cache is shutting down")), cmd);
+ } catch (IllegalLifecycleStateException e) {
+ if (trace) log.trace("Ignoring command unmarshalling error during shutdown");
+ // If this wasn't a CacheRpcCommand, it means the channel is already stopped, and the response won't matter
+ reply(response, CacheNotFoundResponse.INSTANCE, cmd);
} catch (Throwable x) {
if (cmd == null)
log.errorUnMarshallingCommand(x);
Please sign in to comment.
Something went wrong with that request. Please try again.