diff options
author | Beluga Behr <dam6923@gmail.com> | 2019-01-06 15:08:58 -0500 |
---|---|---|
committer | Beluga Behr <dam6923@gmail.com> | 2019-01-14 11:22:02 -0500 |
commit | e20ab3e2371803e69b321f13116e04a926ca39be (patch) | |
tree | 4a7ccb62d6dce54e9fadd31c9fc3807ae8675ef0 /lib/java | |
parent | 4eac57abcfc5f6fb591d894fe446add243392557 (diff) | |
download | thrift-e20ab3e2371803e69b321f13116e04a926ca39be.tar.gz |
THRIFT-4725: Change Return Type Signature of Process Methods
Diffstat (limited to 'lib/java')
9 files changed, 31 insertions, 26 deletions
diff --git a/lib/java/README.md b/lib/java/README.md index 0b5f0d802..505746508 100644 --- a/lib/java/README.md +++ b/lib/java/README.md @@ -164,6 +164,11 @@ http://gradle.org/ # Breaking Changes +## 1.0 + +The signature of the 'process' method in TAsyncProcessor and TProcessor has +changed to remove a boolean return type and to instead rely on Exceptions. + ## 0.12.0 The access modifier of the AutoExpandingBuffer class has been changed from diff --git a/lib/java/src/org/apache/thrift/TAsyncProcessor.java b/lib/java/src/org/apache/thrift/TAsyncProcessor.java index 533e74d86..66f768896 100644 --- a/lib/java/src/org/apache/thrift/TAsyncProcessor.java +++ b/lib/java/src/org/apache/thrift/TAsyncProcessor.java @@ -21,8 +21,13 @@ package org.apache.thrift; import org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer; public interface TAsyncProcessor { - /** - * Implementations must call fb.responseReady() once processing is complete - */ - public boolean process(final AsyncFrameBuffer fb) throws TException; + /** + * Process a single frame. + + * <b>Note:</b> Implementations must call fb.responseReady() once processing + * is complete + * + * @throws TException if the frame cannot be processed + */ + public void process(final AsyncFrameBuffer fb) throws TException; } diff --git a/lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java b/lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java index 0ab1827dc..f13f068ef 100644 --- a/lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java +++ b/lib/java/src/org/apache/thrift/TBaseAsyncProcessor.java @@ -43,7 +43,7 @@ public class TBaseAsyncProcessor<I> implements TAsyncProcessor, TProcessor { return Collections.unmodifiableMap(processMap); } - public boolean process(final AsyncFrameBuffer fb) throws TException { + public void process(final AsyncFrameBuffer fb) throws TException { final TProtocol in = fb.getInputProtocol(); final TProtocol out = fb.getOutputProtocol(); @@ -67,7 +67,7 @@ public class TBaseAsyncProcessor<I> implements TAsyncProcessor, TProcessor { out.getTransport().flush(); } fb.responseReady(); - return true; + return; } //Get Args @@ -89,7 +89,7 @@ public class TBaseAsyncProcessor<I> implements TAsyncProcessor, TProcessor { out.getTransport().flush(); } fb.responseReady(); - return true; + return; } in.readMessageEnd(); @@ -105,11 +105,10 @@ public class TBaseAsyncProcessor<I> implements TAsyncProcessor, TProcessor { LOGGER.debug("Exception handling function", e); resultHandler.onError(e); } - return true; + return; } @Override - public boolean process(TProtocol in, TProtocol out) throws TException { - return false; + public void process(TProtocol in, TProtocol out) throws TException { } } diff --git a/lib/java/src/org/apache/thrift/TBaseProcessor.java b/lib/java/src/org/apache/thrift/TBaseProcessor.java index f9a9a9e37..55a0f15d3 100644 --- a/lib/java/src/org/apache/thrift/TBaseProcessor.java +++ b/lib/java/src/org/apache/thrift/TBaseProcessor.java @@ -23,7 +23,7 @@ public abstract class TBaseProcessor<I> implements TProcessor { } @Override - public boolean process(TProtocol in, TProtocol out) throws TException { + public void process(TProtocol in, TProtocol out) throws TException { TMessage msg = in.readMessageBegin(); ProcessFunction fn = processMap.get(msg.name); if (fn == null) { @@ -34,9 +34,8 @@ public abstract class TBaseProcessor<I> implements TProcessor { x.write(out); out.writeMessageEnd(); out.getTransport().flush(); - return true; + } else { + fn.process(msg.seqid, in, out, iface); } - fn.process(msg.seqid, in, out, iface); - return true; } } diff --git a/lib/java/src/org/apache/thrift/TMultiplexedProcessor.java b/lib/java/src/org/apache/thrift/TMultiplexedProcessor.java index d0c560387..14b541d81 100644 --- a/lib/java/src/org/apache/thrift/TMultiplexedProcessor.java +++ b/lib/java/src/org/apache/thrift/TMultiplexedProcessor.java @@ -92,7 +92,7 @@ public class TMultiplexedProcessor implements TProcessor { * name was not found in the service map. You called {@link #registerProcessor(String, TProcessor) registerProcessor} * during initialization, right? :) */ - public boolean process(TProtocol iprot, TProtocol oprot) throws TException { + public void process(TProtocol iprot, TProtocol oprot) throws TException { /* Use the actual underlying protocol (e.g. TBinaryProtocol) to read the message header. This pulls the message "off the wire", which we'll @@ -109,7 +109,8 @@ public class TMultiplexedProcessor implements TProcessor { if (index < 0) { if (defaultProcessor != null) { // Dispatch processing to the stored processor - return defaultProcessor.process(new StoredMessageProtocol(iprot, message), oprot); + defaultProcessor.process(new StoredMessageProtocol(iprot, message), oprot); + return; } throw new TException("Service name not found in message name: " + message.name + ". Did you " + "forget to use a TMultiplexProtocol in your client?"); @@ -131,7 +132,7 @@ public class TMultiplexedProcessor implements TProcessor { ); // Dispatch processing to the stored processor - return actualProcessor.process(new StoredMessageProtocol(iprot, standardMessage), oprot); + actualProcessor.process(new StoredMessageProtocol(iprot, standardMessage), oprot); } /** diff --git a/lib/java/src/org/apache/thrift/TProcessor.java b/lib/java/src/org/apache/thrift/TProcessor.java index d79522c3e..15ba9c0fe 100644 --- a/lib/java/src/org/apache/thrift/TProcessor.java +++ b/lib/java/src/org/apache/thrift/TProcessor.java @@ -24,9 +24,7 @@ import org.apache.thrift.protocol.TProtocol; /** * A processor is a generic object which operates upon an input stream and * writes to some output stream. - * */ public interface TProcessor { - public boolean process(TProtocol in, TProtocol out) - throws TException; + public void process(TProtocol in, TProtocol out) throws TException; } diff --git a/lib/java/src/org/apache/thrift/server/TSimpleServer.java b/lib/java/src/org/apache/thrift/server/TSimpleServer.java index e815b2cf1..13501efc6 100644 --- a/lib/java/src/org/apache/thrift/server/TSimpleServer.java +++ b/lib/java/src/org/apache/thrift/server/TSimpleServer.java @@ -77,9 +77,7 @@ public class TSimpleServer extends TServer { if (eventHandler_ != null) { eventHandler_.processContext(connectionContext, inputTransport, outputTransport); } - if(!processor.process(inputProtocol, outputProtocol)) { - break; - } + processor.process(inputProtocol, outputProtocol); } } } catch (TTransportException ttx) { diff --git a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java index 1697ad6ae..db1ecb9da 100644 --- a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java +++ b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java @@ -307,9 +307,10 @@ public class TThreadPoolServer extends TServer { eventHandler.processContext(connectionContext, inputTransport, outputTransport); } - if(stopped_ || !processor.process(inputProtocol, outputProtocol)) { + if (stopped_) { break; } + processor.process(inputProtocol, outputProtocol); } } catch (TException tx) { LOGGER.error("Thrift error occurred during processing of message.", tx); diff --git a/lib/java/test/org/apache/thrift/TestMultiplexedProcessor.java b/lib/java/test/org/apache/thrift/TestMultiplexedProcessor.java index 01776ca39..85e7966bf 100644 --- a/lib/java/test/org/apache/thrift/TestMultiplexedProcessor.java +++ b/lib/java/test/org/apache/thrift/TestMultiplexedProcessor.java @@ -57,13 +57,12 @@ public class TestMultiplexedProcessor { static class StubProcessor implements TProcessor { @Override - public boolean process(TProtocol in, TProtocol out) throws TException { + public void process(TProtocol in, TProtocol out) throws TException { TMessage msg = in.readMessageBegin(); if (!"func".equals(msg.name) || msg.type!=TMessageType.CALL || msg.seqid!=42) { throw new TException("incorrect parameters"); } out.writeMessageBegin(new TMessage("func", TMessageType.REPLY, 42)); - return true; } } |