From 31347db71b51355bce6ceac01bfb974fc776918c Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 6 Mar 2018 17:21:15 +1100 Subject: [PATCH] changes after second review from gregw Signed-off-by: Lachlan Roberts --- .../java/org/eclipse/jetty/client/HttpContent.java | 13 ++++++------- .../java/org/eclipse/jetty/deploy/graph/Edge.java | 14 -------------- .../java/org/eclipse/jetty/deploy/graph/Graph.java | 6 +++--- .../java/org/eclipse/jetty/servlets/DoSFilter.java | 2 +- .../common/message/MessageInputStream.java | 8 ++++---- 5 files changed, 14 insertions(+), 29 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContent.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContent.java index 66b24cc677d..0f02a6d970d 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContent.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpContent.java @@ -82,15 +82,14 @@ public class HttpContent implements Callback, Closeable } /** - * * @param buffer - * @return whether the input buffer has been closed + * @return true if the buffer is the sentinel instance {@link CLOSE} */ - private static boolean isBufferClosed(ByteBuffer buffer) + private static boolean isTheCloseBuffer(ByteBuffer buffer) { @SuppressWarnings("ReferenceEquality") - boolean bufferClosed = (buffer == CLOSE); - return bufferClosed; + boolean isTheCloseBuffer = (buffer == CLOSE); + return isTheCloseBuffer; } /** @@ -200,7 +199,7 @@ public class HttpContent implements Callback, Closeable { if (isConsumed()) return; - if (isBufferClosed(buffer)) + if (isTheCloseBuffer(buffer)) return; if (iterator instanceof Callback) ((Callback)iterator).succeeded(); @@ -211,7 +210,7 @@ public class HttpContent implements Callback, Closeable { if (isConsumed()) return; - if (isBufferClosed(buffer)) + if (isTheCloseBuffer(buffer)) return; if (iterator instanceof Callback) ((Callback)iterator).failed(x); diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/graph/Edge.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/graph/Edge.java index af792eedd66..83fec32fcc4 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/graph/Edge.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/graph/Edge.java @@ -74,25 +74,11 @@ public final class Edge return _from; } - public boolean isFromNode(Node node) - { - @SuppressWarnings("ReferenceEquality") - boolean isFromNode_ = (_from == node); - return isFromNode_; - } - public Node getTo() { return _to; } - public boolean isToNode(Node node) - { - @SuppressWarnings("ReferenceEquality") - boolean isToNode_ = (_to == node); - return isToNode_; - } - @Override public String toString() { diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/graph/Graph.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/graph/Graph.java index b05064f7add..a0fe24a7c95 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/graph/Graph.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/graph/Graph.java @@ -40,7 +40,7 @@ public class Graph addNode(toNode=edge.getTo()); // replace edge with normalized edge - if (!edge.isFromNode(fromNode) || !edge.isToNode(toNode)) + if (!edge.getFrom().equals(fromNode) || !edge.getTo().equals(toNode)) edge=new Edge(fromNode,toNode); this._edges.add(edge); @@ -129,7 +129,7 @@ public class Graph for (Edge edge : this._edges) { - if (edge.isFromNode(node) || edge.isToNode(node)) + if (edge.getFrom().equals(node) || edge.getTo().equals(node)) { fromedges.add(edge); } @@ -151,7 +151,7 @@ public class Graph for (Edge edge : this._edges) { - if (edge.isFromNode(from)) + if (edge.getFrom().equals(from)) { fromedges.add(edge); } diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java index 70e2bbe1653..8b37652497c 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java @@ -381,7 +381,7 @@ public class DoSFilter implements Filter // or if we were woken up we insist or we fail. Boolean throttled = (Boolean)request.getAttribute(__THROTTLED); long throttleMs = getThrottleMs(); - if (Boolean.FALSE.equals(throttled) && throttleMs > 0) + if (!Boolean.TRUE.equals(throttled) && throttleMs > 0) { int priority = getPriority(request, tracker); request.setAttribute(__THROTTLED, Boolean.TRUE); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java index a2d87759548..7765127e5bf 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java @@ -45,11 +45,11 @@ public class MessageInputStream extends InputStream implements MessageAppender private final long timeoutMs; private ByteBuffer activeBuffer = null; - private static boolean isBufferEOF(ByteBuffer buf) + private static boolean isTheEofBuffer(ByteBuffer buf) { @SuppressWarnings("ReferenceEquality") - boolean isBufferEOF_ = (buf==EOF); - return isBufferEOF_; + boolean isTheEofBuffer = (buf==EOF); + return isTheEofBuffer; } public MessageInputStream() @@ -173,7 +173,7 @@ public class MessageInputStream extends InputStream implements MessageAppender } } - if (isBufferEOF(activeBuffer)) + if (isTheEofBuffer(activeBuffer)) { if (LOG.isDebugEnabled()) LOG.debug("Reached EOF");