Merge pull request #2257 from lachlan-roberts/jetty-9.4.x-2206-ReferenceEquality
Resolved errorprone ReferenceEquality warnings #2206
This commit is contained in:
commit
bcb9fa3b32
|
@ -81,6 +81,17 @@ public class HttpContent implements Callback, Closeable
|
|||
this.iterator = provider == null ? Collections.<ByteBuffer>emptyIterator() : provider.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param buffer
|
||||
* @return true if the buffer is the sentinel instance {@link CLOSE}
|
||||
*/
|
||||
private static boolean isTheCloseBuffer(ByteBuffer buffer)
|
||||
{
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean isTheCloseBuffer = (buffer == CLOSE);
|
||||
return isTheCloseBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether there is any content at all
|
||||
*/
|
||||
|
@ -177,6 +188,7 @@ public class HttpContent implements Callback, Closeable
|
|||
/**
|
||||
* @return whether the cursor has been advanced past the {@link #isLast() last} position.
|
||||
*/
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public boolean isConsumed()
|
||||
{
|
||||
return buffer == AFTER;
|
||||
|
@ -187,7 +199,7 @@ public class HttpContent implements Callback, Closeable
|
|||
{
|
||||
if (isConsumed())
|
||||
return;
|
||||
if (buffer == CLOSE)
|
||||
if (isTheCloseBuffer(buffer))
|
||||
return;
|
||||
if (iterator instanceof Callback)
|
||||
((Callback)iterator).succeeded();
|
||||
|
@ -198,7 +210,7 @@ public class HttpContent implements Callback, Closeable
|
|||
{
|
||||
if (isConsumed())
|
||||
return;
|
||||
if (buffer == CLOSE)
|
||||
if (isTheCloseBuffer(buffer))
|
||||
return;
|
||||
if (iterator instanceof Callback)
|
||||
((Callback)iterator).failed(x);
|
||||
|
|
|
@ -204,7 +204,10 @@ public class HttpRequest implements Request
|
|||
{
|
||||
if (uri == null)
|
||||
uri = buildURI(true);
|
||||
return uri == NULL_URI ? null : uri;
|
||||
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean isNullURI = (uri == NULL_URI);
|
||||
return isNullURI ? null : uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -321,10 +321,10 @@ public class HttpSenderOverHTTP extends HttpSender
|
|||
private void release()
|
||||
{
|
||||
ByteBufferPool bufferPool = httpClient.getByteBufferPool();
|
||||
if (headerBuffer != BufferUtil.EMPTY_BUFFER)
|
||||
if (!BufferUtil.isTheEmptyBuffer(headerBuffer))
|
||||
bufferPool.release(headerBuffer);
|
||||
headerBuffer = null;
|
||||
if (chunkBuffer != BufferUtil.EMPTY_BUFFER)
|
||||
if (!BufferUtil.isTheEmptyBuffer(chunkBuffer))
|
||||
bufferPool.release(chunkBuffer);
|
||||
chunkBuffer = null;
|
||||
contentBuffer = null;
|
||||
|
|
|
@ -589,6 +589,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
|||
public ByteBuffer current;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public boolean hasNext()
|
||||
{
|
||||
if (current == null)
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
|
@ -311,10 +312,12 @@ public class DeploymentManager extends ContainerLifeCycle
|
|||
*/
|
||||
public Collection<App> getApps(Node node)
|
||||
{
|
||||
Objects.requireNonNull(node);
|
||||
|
||||
List<App> ret = new ArrayList<>();
|
||||
for (AppEntry entry : _apps)
|
||||
{
|
||||
if (entry.lifecyleNode == node)
|
||||
if (node.equals(entry.lifecyleNode))
|
||||
{
|
||||
ret.add(entry.app);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@ public final class Edge
|
|||
|
||||
public Edge(Node from, Node to)
|
||||
{
|
||||
if (from==null || to==null || from==to)
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean sameObject = (from==to);
|
||||
if (from==null || to==null || sameObject)
|
||||
throw new IllegalArgumentException("from "+from+" to "+to);
|
||||
_from = from;
|
||||
_to = to;
|
||||
|
@ -71,7 +73,7 @@ public final class Edge
|
|||
{
|
||||
return _from;
|
||||
}
|
||||
|
||||
|
||||
public Node getTo()
|
||||
{
|
||||
return _to;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class Graph
|
|||
addNode(toNode=edge.getTo());
|
||||
|
||||
// replace edge with normalized edge
|
||||
if (edge.getFrom()!=fromNode || edge.getTo()!=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.getFrom() == node) || (edge.getTo() == 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.getFrom() == from)
|
||||
if (edge.getFrom().equals(from))
|
||||
{
|
||||
fromedges.add(edge);
|
||||
}
|
||||
|
@ -192,7 +192,9 @@ public class Graph
|
|||
*/
|
||||
public Path getPath(Node from, Node to)
|
||||
{
|
||||
if (from == to)
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean sameObject = (from==to);
|
||||
if (sameObject)
|
||||
{
|
||||
return new Path();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class DeploymentManagerMBean extends ObjectMBean
|
|||
List<String> ret = new ArrayList<>();
|
||||
for (DeploymentManager.AppEntry entry : _manager.getAppEntries())
|
||||
{
|
||||
if (entry.getLifecyleNode() == node)
|
||||
if (node.equals(entry.getLifecyleNode()))
|
||||
{
|
||||
ret.add(toRef(entry.getApp()));
|
||||
}
|
||||
|
|
|
@ -127,7 +127,9 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
|
|||
|
||||
private void releaseBuffer(ByteBuffer buffer)
|
||||
{
|
||||
assert this.buffer == buffer;
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean isCurrentBuffer = (this.buffer == buffer);
|
||||
assert(isCurrentBuffer);
|
||||
HttpClient client = destination.getHttpClient();
|
||||
ByteBufferPool bufferPool = client.getByteBufferPool();
|
||||
bufferPool.release(buffer);
|
||||
|
|
|
@ -417,7 +417,9 @@ public class GZIPContentDecoder implements Destroyable
|
|||
*/
|
||||
public void release(ByteBuffer buffer)
|
||||
{
|
||||
if (_pool!=null && buffer!=BufferUtil.EMPTY_BUFFER)
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean isTheEmptyBuffer = (buffer==BufferUtil.EMPTY_BUFFER);
|
||||
if (_pool!=null && !isTheEmptyBuffer)
|
||||
_pool.release(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,9 +276,12 @@ public class HttpField
|
|||
|
||||
public boolean isSameName(HttpField field)
|
||||
{
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean sameObject = (field==this);
|
||||
|
||||
if (field==null)
|
||||
return false;
|
||||
if (field==this)
|
||||
if (sameObject)
|
||||
return true;
|
||||
if (_header!=null && _header==field.getHeader())
|
||||
return true;
|
||||
|
|
|
@ -2025,6 +2025,7 @@ public class HttpParserTest
|
|||
Assert.assertEquals(null, _bad);
|
||||
}
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testCachedField() throws Exception
|
||||
{
|
||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||
|
|
|
@ -131,6 +131,7 @@ public class HpackContextTest
|
|||
assertNull(ctx.get("name"));
|
||||
}
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testGetAddStatic()
|
||||
{
|
||||
HpackContext ctx = new HpackContext(4096);
|
||||
|
|
|
@ -202,7 +202,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
|||
throw new ClosedChannelException();
|
||||
|
||||
ByteBuffer in = _inQ.peek();
|
||||
if (BufferUtil.hasContent(in) || in==EOF)
|
||||
if (BufferUtil.hasContent(in) || isEOF(in))
|
||||
execute(_runFillable);
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
|||
boolean fillable=false;
|
||||
try(Locker.Lock lock = _locker.lock())
|
||||
{
|
||||
if (_inQ.peek()==EOF)
|
||||
if (isEOF(_inQ.peek()))
|
||||
throw new RuntimeIOException(new EOFException());
|
||||
boolean was_empty=_inQ.isEmpty();
|
||||
if (in==null)
|
||||
|
@ -248,7 +248,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
|||
boolean fillable=false;
|
||||
try(Locker.Lock lock = _locker.lock())
|
||||
{
|
||||
if (_inQ.peek()==EOF)
|
||||
if (isEOF(_inQ.peek()))
|
||||
throw new RuntimeIOException(new EOFException());
|
||||
boolean was_empty=_inQ.isEmpty();
|
||||
if (in==null)
|
||||
|
@ -415,7 +415,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
|||
break;
|
||||
|
||||
ByteBuffer in= _inQ.peek();
|
||||
if (in==EOF)
|
||||
if (isEOF(in))
|
||||
{
|
||||
filled=-1;
|
||||
break;
|
||||
|
@ -550,4 +550,16 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
|||
return String.format("%s[q=%d,q[0]=%s,o=%s]",super.toString(),q,b,o);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Compares a ByteBuffer Object to EOF by Reference
|
||||
* @param buffer the input ByteBuffer to be compared to EOF
|
||||
* @return Whether the reference buffer is equal to that of EOF
|
||||
*/
|
||||
private static boolean isEOF(ByteBuffer buffer)
|
||||
{
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean is_EOF = (buffer==EOF);
|
||||
return is_EOF;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -627,8 +627,12 @@ public class SslConnection extends AbstractConnection
|
|||
|
||||
// We also need an app buffer, but can use the passed buffer if it is big enough
|
||||
ByteBuffer app_in;
|
||||
boolean used_passed_buffer = false;
|
||||
if (BufferUtil.space(buffer) > _sslEngine.getSession().getApplicationBufferSize())
|
||||
{
|
||||
app_in = buffer;
|
||||
used_passed_buffer = true;
|
||||
}
|
||||
else if (_decryptedInput == null)
|
||||
app_in = _decryptedInput = _bufferPool.acquire(_sslEngine.getSession().getApplicationBufferSize(), _decryptedDirectBuffers);
|
||||
else
|
||||
|
@ -730,7 +734,7 @@ public class SslConnection extends AbstractConnection
|
|||
// another call to fill() or flush().
|
||||
if (unwrapResult.bytesProduced() > 0)
|
||||
{
|
||||
if (app_in == buffer)
|
||||
if (used_passed_buffer)
|
||||
return unwrapResult.bytesProduced();
|
||||
return BufferUtil.append(buffer,_decryptedInput);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Arrays;
|
|||
import org.eclipse.jetty.io.ByteBufferPool.Bucket;
|
||||
import org.junit.Test;
|
||||
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public class ArrayByteBufferPoolTest
|
||||
{
|
||||
@Test
|
||||
|
@ -113,6 +114,7 @@ public class ArrayByteBufferPoolTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testAcquireReleaseAcquire() throws Exception
|
||||
{
|
||||
ArrayByteBufferPool bufferPool = new ArrayByteBufferPool(10,100,1000);
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ValidUrlRule extends Rule
|
|||
|
||||
LOG.debug("{} {} {} {}", Character.charCount(codepoint), codepoint, block, Character.isISOControl(codepoint));
|
||||
|
||||
return (!Character.isISOControl(codepoint)) && block != null && block != Character.UnicodeBlock.SPECIALS;
|
||||
return (!Character.isISOControl(codepoint)) && block != null && !Character.UnicodeBlock.SPECIALS.equals(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -428,7 +428,10 @@ public class HttpChannelOverHttp extends HttpChannel implements HttpParser.Reque
|
|||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("upgrade {} {}", this, _upgrade);
|
||||
|
||||
if (_upgrade != PREAMBLE_UPGRADE_H2C && (_connection == null || !_connection.contains("upgrade")))
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean isUpgraded_H2C = (_upgrade == PREAMBLE_UPGRADE_H2C);
|
||||
|
||||
if (!isUpgraded_H2C && (_connection == null || !_connection.contains("upgrade")))
|
||||
throw new BadMessageException(HttpStatus.BAD_REQUEST_400);
|
||||
|
||||
// Find the upgrade factory
|
||||
|
@ -465,7 +468,7 @@ public class HttpChannelOverHttp extends HttpChannel implements HttpParser.Reque
|
|||
// Send 101 if needed
|
||||
try
|
||||
{
|
||||
if (_upgrade != PREAMBLE_UPGRADE_H2C)
|
||||
if (!isUpgraded_H2C)
|
||||
sendResponse(new MetaData.Response(HttpVersion.HTTP_1_1, HttpStatus.SWITCHING_PROTOCOLS_101, response101, 0), null, true);
|
||||
}
|
||||
catch (IOException e)
|
||||
|
|
|
@ -143,6 +143,18 @@ public class Request implements HttpServletRequest
|
|||
|
||||
private static final MultiMap<String> NO_PARAMS = new MultiMap<>();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Compare inputParameters to NO_PARAMS by Reference
|
||||
* @param inputParameters The parameters to compare to NO_PARAMS
|
||||
* @return True if the inputParameters reference is equal to NO_PARAMS otherwise False
|
||||
*/
|
||||
private static boolean isNoParams(MultiMap<String> inputParameters) {
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean is_no_params = (inputParameters==NO_PARAMS);
|
||||
return is_no_params;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Obtain the base {@link Request} instance of a {@link ServletRequest}, by
|
||||
|
@ -397,9 +409,9 @@ public class Request implements HttpServletRequest
|
|||
}
|
||||
|
||||
// Do parameters need to be combined?
|
||||
if (_queryParameters==NO_PARAMS || _queryParameters.size()==0)
|
||||
if (isNoParams(_queryParameters) || _queryParameters.size()==0)
|
||||
_parameters=_contentParameters;
|
||||
else if (_contentParameters==NO_PARAMS || _contentParameters.size()==0)
|
||||
else if (isNoParams(_contentParameters) || _contentParameters.size()==0)
|
||||
_parameters=_queryParameters;
|
||||
else
|
||||
{
|
||||
|
|
|
@ -452,16 +452,30 @@ public class ResponseWriter extends PrintWriter
|
|||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter format(Locale l, String format, Object... args)
|
||||
public PrintWriter format(Locale locale, String format, Object... args)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
/* If the passed locale is null then
|
||||
use any locale set on the response as the default. */
|
||||
if(locale == null)
|
||||
locale = _locale;
|
||||
|
||||
synchronized (lock)
|
||||
{
|
||||
isOpen();
|
||||
if ((_formatter == null) || (_formatter.locale() != l))
|
||||
_formatter = new Formatter(this, l);
|
||||
_formatter.format(l, format, args);
|
||||
|
||||
if(_formatter == null)
|
||||
{
|
||||
_formatter = new Formatter(this, locale);
|
||||
}
|
||||
else if (!_formatter.locale().equals(locale))
|
||||
{
|
||||
_formatter = new Formatter(this, locale);
|
||||
}
|
||||
|
||||
_formatter.format(locale, format, args);
|
||||
}
|
||||
}
|
||||
catch (InterruptedIOException ex)
|
||||
|
|
|
@ -63,6 +63,7 @@ import org.eclipse.jetty.server.session.Session;
|
|||
import org.eclipse.jetty.server.session.SessionData;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
import org.eclipse.jetty.util.thread.TimerScheduler;
|
||||
|
@ -112,10 +113,13 @@ public class ResponseTest
|
|||
|
||||
private Server _server;
|
||||
private HttpChannel _channel;
|
||||
private ByteBuffer _content = BufferUtil.allocate(16*1024);
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
BufferUtil.clear(_content);
|
||||
|
||||
_server = new Server();
|
||||
Scheduler _scheduler = new TimerScheduler();
|
||||
HttpConfiguration config = new HttpConfiguration();
|
||||
|
@ -139,6 +143,12 @@ public class ResponseTest
|
|||
@Override
|
||||
public void send(MetaData.Response info, boolean head, ByteBuffer content, boolean lastContent, Callback callback)
|
||||
{
|
||||
if(BufferUtil.hasContent(content))
|
||||
{
|
||||
BufferUtil.append(_content, content);
|
||||
}
|
||||
|
||||
|
||||
if (_channelError==null)
|
||||
callback.succeeded();
|
||||
else
|
||||
|
@ -172,6 +182,7 @@ public class ResponseTest
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -364,6 +375,54 @@ public class ResponseTest
|
|||
assertTrue(response.toString().indexOf("charset=utf-8") > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocaleFormat() throws Exception
|
||||
{
|
||||
Response response = getResponse();
|
||||
|
||||
ContextHandler context = new ContextHandler();
|
||||
context.addLocaleEncoding(Locale.ENGLISH.toString(), "ISO-8859-1");
|
||||
context.addLocaleEncoding(Locale.ITALIAN.toString(), "ISO-8859-2");
|
||||
response.getHttpChannel().getRequest().setContext(context.getServletContext());
|
||||
|
||||
response.setLocale(java.util.Locale.ITALIAN);
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
out.format("TestA1 %,.2f%n", 1234567.89);
|
||||
out.format("TestA2 %,.2f%n", 1234567.89);
|
||||
|
||||
out.format((java.util.Locale)null,"TestB1 %,.2f%n", 1234567.89);
|
||||
out.format((java.util.Locale)null,"TestB2 %,.2f%n", 1234567.89);
|
||||
|
||||
out.format(Locale.ENGLISH,"TestC1 %,.2f%n", 1234567.89);
|
||||
out.format(Locale.ENGLISH,"TestC2 %,.2f%n", 1234567.89);
|
||||
|
||||
out.format(Locale.ITALIAN,"TestD1 %,.2f%n", 1234567.89);
|
||||
out.format(Locale.ITALIAN,"TestD2 %,.2f%n", 1234567.89);
|
||||
|
||||
out.close();
|
||||
|
||||
/* Test A */
|
||||
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestA1 1.234.567,89"));
|
||||
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestA2 1.234.567,89"));
|
||||
|
||||
/* Test B */
|
||||
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestB1 1.234.567,89"));
|
||||
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestB2 1.234.567,89"));
|
||||
|
||||
/* Test C */
|
||||
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestC1 1,234,567.89"));
|
||||
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestC2 1,234,567.89"));
|
||||
|
||||
/* Test D */
|
||||
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestD1 1.234.567,89"));
|
||||
Assert.assertThat(BufferUtil.toString(_content),Matchers.containsString("TestD2 1.234.567,89"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testContentTypeCharacterEncoding() throws Exception
|
||||
{
|
||||
|
|
|
@ -514,7 +514,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc
|
|||
if ((_welcomeServlets || _welcomeExactServlets) && welcome_servlet==null)
|
||||
{
|
||||
MappedResource<ServletHolder> entry=_servletHandler.getMappedServlet(welcome_in_context);
|
||||
if (entry!=null && entry.getResource()!=_defaultHolder &&
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean isDefaultHolder = (entry.getResource()!=_defaultHolder);
|
||||
if (entry!=null && isDefaultHolder &&
|
||||
(_welcomeServlets || (_welcomeExactServlets && entry.getPathSpec().getDeclaration().equals(welcome_in_context))))
|
||||
welcome_servlet=welcome_in_context;
|
||||
|
||||
|
|
|
@ -1513,7 +1513,9 @@ public class ServletHandler extends ScopedHandler
|
|||
boolean found = false;
|
||||
for (ServletHolder s:_servlets)
|
||||
{
|
||||
if (s == holder)
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean foundServletHolder = (s == holder);
|
||||
if (foundServletHolder)
|
||||
found = true;
|
||||
}
|
||||
return found;
|
||||
|
|
|
@ -383,7 +383,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 (throttled != Boolean.TRUE && throttleMs > 0)
|
||||
if (!Boolean.TRUE.equals(throttled) && throttleMs > 0)
|
||||
{
|
||||
int priority = getPriority(request, tracker);
|
||||
request.setAttribute(__THROTTLED, Boolean.TRUE);
|
||||
|
@ -401,7 +401,7 @@ public class DoSFilter implements Filter
|
|||
}
|
||||
|
||||
Boolean resumed = (Boolean)request.getAttribute(_resumed);
|
||||
if (resumed == Boolean.TRUE)
|
||||
if (Boolean.TRUE.equals(resumed))
|
||||
{
|
||||
// We were resumed, we wait for the next pass.
|
||||
_passes.acquire();
|
||||
|
@ -446,7 +446,7 @@ public class DoSFilter implements Filter
|
|||
{
|
||||
ServletRequest candidate = asyncContext.getRequest();
|
||||
Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
|
||||
if (suspended == Boolean.TRUE)
|
||||
if (Boolean.TRUE.equals(suspended))
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Resuming {}", request);
|
||||
|
|
|
@ -173,7 +173,7 @@ public class QoSFilter implements Filter
|
|||
{
|
||||
request.setAttribute(_suspended, Boolean.FALSE);
|
||||
Boolean resumed = (Boolean)request.getAttribute(_resumed);
|
||||
if (resumed == Boolean.TRUE)
|
||||
if (Boolean.TRUE.equals(resumed))
|
||||
{
|
||||
_passes.acquire();
|
||||
accepted = true;
|
||||
|
@ -224,7 +224,7 @@ public class QoSFilter implements Filter
|
|||
{
|
||||
ServletRequest candidate = asyncContext.getRequest();
|
||||
Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
|
||||
if (suspended == Boolean.TRUE)
|
||||
if (Boolean.TRUE.equals(suspended))
|
||||
{
|
||||
candidate.setAttribute(_resumed, Boolean.TRUE);
|
||||
asyncContext.dispatch();
|
||||
|
|
|
@ -305,7 +305,7 @@ public class Modules implements Iterable<Module>
|
|||
{
|
||||
for (Module p:providers)
|
||||
{
|
||||
if (p!=module && p.isEnabled())
|
||||
if (!p.equals(module) && p.isEnabled())
|
||||
{
|
||||
// If the already enabled module is transitive and this enable is not
|
||||
if (p.isTransitive() && !transitive)
|
||||
|
@ -364,8 +364,8 @@ public class Modules implements Iterable<Module>
|
|||
}
|
||||
|
||||
// If a provider is already enabled, then add a transitive enable
|
||||
if (providers.stream().filter(Module::isEnabled).count()!=0)
|
||||
providers.stream().filter(m->m.isEnabled()&&m!=module).forEach(m->enable(newlyEnabled,m,"transitive provider of "+dependsOn+" for "+module.getName(),true));
|
||||
if (providers.stream().filter(Module::isEnabled).count()>0)
|
||||
providers.stream().filter(m->m.isEnabled()&&!m.equals(module)).forEach(m->enable(newlyEnabled,m,"transitive provider of "+dependsOn+" for "+module.getName(),true));
|
||||
else
|
||||
{
|
||||
// Is there an obvious default?
|
||||
|
|
|
@ -238,6 +238,17 @@ public class BufferUtil
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param buf the buffer to check
|
||||
* @return true if buf is equal to EMPTY_BUFFER
|
||||
*/
|
||||
public static boolean isTheEmptyBuffer(ByteBuffer buf)
|
||||
{
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean isTheEmptyBuffer_ = (buf == EMPTY_BUFFER);
|
||||
return isTheEmptyBuffer_;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Check for an empty or null buffer.
|
||||
* @param buf the buffer to check
|
||||
|
|
|
@ -251,6 +251,7 @@ public class Fields implements Iterable<Fields.Field>
|
|||
this.values = Collections.unmodifiableList(list);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public boolean equals(Field that, boolean caseSensitive)
|
||||
{
|
||||
if (this == that)
|
||||
|
|
|
@ -221,7 +221,7 @@ public class UrlEncoded extends MultiMap<String> implements Cloneable
|
|||
if (charset==null)
|
||||
charset=ENCODING;
|
||||
|
||||
if (charset==StandardCharsets.UTF_8)
|
||||
if (StandardCharsets.UTF_8.equals(charset))
|
||||
{
|
||||
decodeUtf8To(content,0,content.length(),map);
|
||||
return;
|
||||
|
|
|
@ -211,7 +211,9 @@ public class StdErrLog extends AbstractLogger
|
|||
*/
|
||||
public StdErrLog(String name, Properties props)
|
||||
{
|
||||
if (props!=null && props!=Log.__props)
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean sameObject = (props!=Log.__props);
|
||||
if (props!=null && sameObject)
|
||||
Log.__props.putAll(props);
|
||||
_name = name == null?"":name;
|
||||
_abbrevname = condensePackageString(this._name);
|
||||
|
|
|
@ -407,6 +407,7 @@ public class FileResource extends Resource
|
|||
* @return <code>true</code> of the object <code>o</code> is a {@link FileResource} pointing to the same file as this resource.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public boolean equals( Object o)
|
||||
{
|
||||
if (this == o)
|
||||
|
@ -416,7 +417,7 @@ public class FileResource extends Resource
|
|||
return false;
|
||||
|
||||
FileResource f=(FileResource)o;
|
||||
return f._file == _file || (null != _file && _file.equals(f._file));
|
||||
return f._file==_file || (null != _file && _file.equals(f._file));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -95,7 +95,9 @@ public abstract class Credential implements Serializable
|
|||
*/
|
||||
protected static boolean stringEquals(String known, String unknown)
|
||||
{
|
||||
if (known == unknown)
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean sameObject = (known == unknown);
|
||||
if (sameObject)
|
||||
return true;
|
||||
if (known == null || unknown == null)
|
||||
return false;
|
||||
|
|
|
@ -297,6 +297,7 @@ public class BufferUtilTest
|
|||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testEnsureCapacity() throws Exception
|
||||
{
|
||||
ByteBuffer b = BufferUtil.toBuffer("Goodbye Cruel World");
|
||||
|
|
|
@ -40,6 +40,7 @@ public class DateCacheTest
|
|||
/* ------------------------------------------------------------ */
|
||||
@Test
|
||||
@Slow
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testDateCache() throws Exception
|
||||
{
|
||||
//@WAS: Test t = new Test("org.eclipse.jetty.util.DateCache");
|
||||
|
|
|
@ -36,6 +36,7 @@ import static org.junit.Assert.assertTrue;
|
|||
public class StringUtilTest
|
||||
{
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testAsciiToLowerCase()
|
||||
{
|
||||
String lc="\u0690bc def 1\u06903";
|
||||
|
@ -88,6 +89,7 @@ public class StringUtilTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testReplace()
|
||||
{
|
||||
String s="\u0690bc \u0690bc \u0690bc";
|
||||
|
@ -100,6 +102,7 @@ public class StringUtilTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testUnquote()
|
||||
{
|
||||
String uq =" not quoted ";
|
||||
|
@ -112,9 +115,10 @@ public class StringUtilTest
|
|||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testNonNull()
|
||||
{
|
||||
String nn="";
|
||||
String nn="non empty string";
|
||||
assertTrue(nn==StringUtil.nonNull(nn));
|
||||
assertEquals("",StringUtil.nonNull(null));
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ public class TopologicalSortTest
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
private int indexOf(String[] list,String s)
|
||||
{
|
||||
for (int i=0;i<list.length;i++)
|
||||
|
|
|
@ -696,9 +696,9 @@ public class ClasspathPattern extends AbstractSet<String>
|
|||
LOG.debug("match {} from {} byName={} byLocation={} in {}",clazz,location,byName,byLocation,this);
|
||||
|
||||
// Combine the tri-state match of both IncludeExclude Sets
|
||||
boolean included = byName==Boolean.TRUE || byLocation==Boolean.TRUE
|
||||
boolean included = Boolean.TRUE.equals(byName) || Boolean.TRUE.equals(byLocation)
|
||||
|| (byName==null && !_patterns.hasIncludes() && byLocation==null && !_locations.hasIncludes());
|
||||
boolean excluded = byName==Boolean.FALSE || byLocation==Boolean.FALSE;
|
||||
boolean excluded = Boolean.FALSE.equals(byName) || Boolean.FALSE.equals(byLocation);
|
||||
return included && !excluded;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -737,9 +737,9 @@ public class ClasspathPattern extends AbstractSet<String>
|
|||
}
|
||||
|
||||
// Combine the tri-state match of both IncludeExclude Sets
|
||||
boolean included = byName==Boolean.TRUE || byLocation==Boolean.TRUE
|
||||
boolean included = Boolean.TRUE.equals(byName) || Boolean.TRUE.equals(byLocation)
|
||||
|| (byName==null && !_patterns.hasIncludes() && byLocation==null && !_locations.hasIncludes());
|
||||
boolean excluded = byName==Boolean.FALSE || byLocation==Boolean.FALSE;
|
||||
boolean excluded = Boolean.FALSE.equals(byName) || Boolean.FALSE.equals(byLocation);
|
||||
return included && !excluded;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,13 @@ public class MessageInputStream extends InputStream implements MessageAppender
|
|||
private final long timeoutMs;
|
||||
private ByteBuffer activeBuffer = null;
|
||||
|
||||
private static boolean isTheEofBuffer(ByteBuffer buf)
|
||||
{
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
boolean isTheEofBuffer = (buf==EOF);
|
||||
return isTheEofBuffer;
|
||||
}
|
||||
|
||||
public MessageInputStream()
|
||||
{
|
||||
this(-1);
|
||||
|
@ -166,7 +173,7 @@ public class MessageInputStream extends InputStream implements MessageAppender
|
|||
}
|
||||
}
|
||||
|
||||
if (activeBuffer == EOF)
|
||||
if (isTheEofBuffer(activeBuffer))
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Reached EOF");
|
||||
|
|
|
@ -87,6 +87,7 @@ public abstract class AbstractSessionInvalidateCreateScavengeTest extends Abstra
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public void testSessionScavenge() throws Exception
|
||||
{
|
||||
String contextPath = "/";
|
||||
|
|
Loading…
Reference in New Issue