diff options
author | Jiayu Liu <Jimexist@users.noreply.github.com> | 2022-05-06 12:56:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-06 00:56:42 -0400 |
commit | 53ec08228a14130909d4dd6fc2c98f47a09d76b0 (patch) | |
tree | 19fd3589502b5471be23efe4d1190ad26fcbc91e /lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java | |
parent | 23b86364ef3dbccc19f5f3828e6d115f7b015651 (diff) | |
download | thrift-53ec08228a14130909d4dd6fc2c98f47a09d76b0.tar.gz |
THRIFT-5568: enforce consistent Java formatting (#2581)
* use spotless plugin and google-java-format to enforce a consistent code format
* add a step of spotless check before building
* only run spotless on the src/ directory
Co-authored-by: Christopher Tubbs <ctubbsii@apache.org>
Diffstat (limited to 'lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java')
-rw-r--r-- | lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java | 76 |
1 files changed, 34 insertions, 42 deletions
diff --git a/lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java b/lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java index 75082c0f7..5773e9c3c 100644 --- a/lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java +++ b/lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java @@ -25,14 +25,12 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Map; - import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.apache.thrift.TException; import org.apache.thrift.TProcessor; import org.apache.thrift.protocol.TProtocol; @@ -41,12 +39,11 @@ import org.apache.thrift.transport.TIOStreamTransport; import org.apache.thrift.transport.TTransport; /** - * Servlet implementation class ThriftServer, that allows {@link TProcessor} and - * {@link TProtocolFactory} to be supplied after the {@link #init()} method has - * finished. <br> - * Subclasses must implement the abstract methods that return the TProcessor and - * two TProtocolFactory. Those methods are guaranteed to be called exactly once, - * and that {@link ServletContext} is available. + * Servlet implementation class ThriftServer, that allows {@link TProcessor} and {@link + * TProtocolFactory} to be supplied after the {@link #init()} method has finished. <br> + * Subclasses must implement the abstract methods that return the TProcessor and two + * TProtocolFactory. Those methods are guaranteed to be called exactly once, and that {@link + * ServletContext} is available. */ public abstract class TExtensibleServlet extends HttpServlet { private static final long serialVersionUID = 1L; @@ -60,32 +57,32 @@ public abstract class TExtensibleServlet extends HttpServlet { private Collection<Map.Entry<String, String>> customHeaders; /** - * Returns the appropriate {@link TProcessor}. This will be called <b>once</b> just - * after the {@link #init()} method - * + * Returns the appropriate {@link TProcessor}. This will be called <b>once</b> just after the + * {@link #init()} method + * * @return the appropriate {@link TProcessor} */ protected abstract TProcessor getProcessor(); /** - * Returns the appropriate in {@link TProtocolFactory}. This will be called - * <b>once</b> just after the {@link #init()} method - * + * Returns the appropriate in {@link TProtocolFactory}. This will be called <b>once</b> just after + * the {@link #init()} method + * * @return the appropriate in {@link TProtocolFactory} */ protected abstract TProtocolFactory getInProtocolFactory(); /** - * Returns the appropriate out {@link TProtocolFactory}. This will be called - * <b>once</b> just after the {@link #init()} method - * + * Returns the appropriate out {@link TProtocolFactory}. This will be called <b>once</b> just + * after the {@link #init()} method + * * @return the appropriate out {@link TProtocolFactory} */ protected abstract TProtocolFactory getOutProtocolFactory(); @Override public final void init(ServletConfig config) throws ServletException { - super.init(config); //no-args init() happens here + super.init(config); // no-args init() happens here this.processor = getProcessor(); this.inFactory = getInProtocolFactory(); this.outFactory = getOutProtocolFactory(); @@ -102,10 +99,7 @@ public abstract class TExtensibleServlet extends HttpServlet { } } - /** - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse - * response) - */ + /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -116,9 +110,9 @@ public abstract class TExtensibleServlet extends HttpServlet { response.setContentType("application/x-thrift"); if (null != this.customHeaders) { - for (Map.Entry<String, String> header : this.customHeaders) { - response.addHeader(header.getKey(), header.getValue()); - } + for (Map.Entry<String, String> header : this.customHeaders) { + response.addHeader(header.getKey(), header.getValue()); + } } InputStream in = request.getInputStream(); @@ -138,10 +132,7 @@ public abstract class TExtensibleServlet extends HttpServlet { } } - /** - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse - * response) - */ + /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { @@ -149,19 +140,20 @@ public abstract class TExtensibleServlet extends HttpServlet { } public void addCustomHeader(final String key, final String value) { - this.customHeaders.add(new Map.Entry<String, String>() { - public String getKey() { - return key; - } - - public String getValue() { - return value; - } - - public String setValue(String value) { - return null; - } - }); + this.customHeaders.add( + new Map.Entry<String, String>() { + public String getKey() { + return key; + } + + public String getValue() { + return value; + } + + public String setValue(String value) { + return null; + } + }); } public void setCustomHeaders(Collection<Map.Entry<String, String>> headers) { |