You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2014/03/10 15:08:44 UTC
svn commit: r1575946 - in /tomcat/trunk/java/org/apache: coyote/ajp/
coyote/http11/ coyote/http11/upgrade/ tomcat/util/net/
Author: remm
Date: Mon Mar 10 14:08:43 2014
New Revision: 1575946
URL: http://svn.apache.org/r1575946
Log:
Fix reported boxing warnings.
Modified:
tomcat/trunk/java/org/apache/coyote/ajp/AjpNio2Processor.java
tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java
tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java
tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpNio2Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpNio2Processor.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpNio2Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpNio2Processor.java Mon Mar 10 14:08:43 2014
@@ -64,7 +64,7 @@ public class AjpNio2Processor extends Ab
public void completed(Integer nBytes, SocketWrapper<Nio2Channel> attachment) {
boolean notify = false;
synchronized (writeCompletionHandler) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
failed(new IOException(sm.getString("ajpprocessor.failedsend")), attachment);
return;
}
@@ -158,7 +158,8 @@ public class AjpNio2Processor extends Ab
writeBuffer.put(src, offset, length);
writeBuffer.flip();
try {
- result = socketWrapper.getSocket().write(writeBuffer).get(socketWrapper.getTimeout(), TimeUnit.MILLISECONDS);
+ result = socketWrapper.getSocket().write(writeBuffer)
+ .get(socketWrapper.getTimeout(), TimeUnit.MILLISECONDS).intValue();
} catch (InterruptedException | ExecutionException
| TimeoutException e) {
throw new IOException(sm.getString("ajpprocessor.failedsend"), e);
@@ -228,7 +229,8 @@ public class AjpNio2Processor extends Ab
flipped = false;
readBuffer.limit(n);
try {
- nRead = socketWrapper.getSocket().read(readBuffer).get(socketWrapper.getTimeout(), TimeUnit.MILLISECONDS);
+ nRead = socketWrapper.getSocket().read(readBuffer)
+ .get(socketWrapper.getTimeout(), TimeUnit.MILLISECONDS).intValue();
} catch (InterruptedException | ExecutionException
| TimeoutException e) {
throw new IOException(sm.getString("ajpprocessor.failedread"), e);
Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java Mon Mar 10 14:08:43 2014
@@ -753,7 +753,7 @@ public class InternalNio2InputBuffer ext
public void completed(Integer nBytes, SocketWrapper<Nio2Channel> attachment) {
boolean notify = false;
synchronized (completionHandler) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
failed(new ClosedChannelException(), attachment);
return;
}
@@ -817,7 +817,8 @@ public class InternalNio2InputBuffer ext
byteBuffer.clear();
flipped = false;
try {
- nRead = socket.getSocket().read(byteBuffer).get(socket.getTimeout(), TimeUnit.MILLISECONDS);
+ nRead = socket.getSocket().read(byteBuffer)
+ .get(socket.getTimeout(), TimeUnit.MILLISECONDS).intValue();
} catch (InterruptedException | ExecutionException
| TimeoutException e) {
throw new EOFException(sm.getString("iib.eof.error"));
Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java Mon Mar 10 14:08:43 2014
@@ -115,7 +115,7 @@ public class InternalNio2OutputBuffer ex
public void completed(Integer nBytes, SocketWrapper<Nio2Channel> attachment) {
boolean notify = false;
synchronized (completionHandler) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
failed(new IOException(sm.getString("iob.failedwrite")), attachment);
return;
}
@@ -162,7 +162,7 @@ public class InternalNio2OutputBuffer ex
public void completed(Long nBytes, ByteBuffer[] attachment) {
boolean notify = false;
synchronized (completionHandler) {
- if (nBytes < 0) {
+ if (nBytes.longValue() < 0) {
failed(new IOException(sm.getString("iob.failedwrite")), attachment);
return;
}
@@ -410,7 +410,7 @@ public class InternalNio2OutputBuffer ex
Nio2Endpoint.startInline();
if (bufferedWrites.size() > 0) {
// Gathering write of the main buffer plus all leftovers
- ArrayList<ByteBuffer> arrayList = new ArrayList<ByteBuffer>();
+ ArrayList<ByteBuffer> arrayList = new ArrayList<>();
if (byteBuffer.hasRemaining()) {
arrayList.add(byteBuffer);
}
Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java Mon Mar 10 14:08:43 2014
@@ -45,13 +45,13 @@ public class Nio2ServletInputStream exte
@Override
public void completed(Integer nBytes, SocketWrapper<Nio2Channel> attachment) {
synchronized (completionHandler) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
failed(new ClosedChannelException(), attachment);
return;
}
readPending = false;
}
- if (nBytes > 0) {
+ if (nBytes.intValue() > 0) {
if (!Nio2Endpoint.isInline()) {
try {
onDataAvailable();
@@ -205,7 +205,7 @@ public class Nio2ServletInputStream exte
flipped = false;
try {
nRead = channel.read(readBuffer)
- .get(wrapper.getTimeout(), TimeUnit.MILLISECONDS);
+ .get(wrapper.getTimeout(), TimeUnit.MILLISECONDS).intValue();
readPending = false;
} catch (InterruptedException | ExecutionException
| TimeoutException e) {
Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java Mon Mar 10 14:08:43 2014
@@ -46,7 +46,7 @@ public class Nio2ServletOutputStream ext
@Override
public void completed(Integer nBytes, SocketWrapper<Nio2Channel> attachment) {
synchronized (completionHandler) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
failed(new ClosedChannelException(), attachment);
return;
}
@@ -122,7 +122,7 @@ public class Nio2ServletOutputStream ext
buffer.put(b, off, len);
buffer.flip();
try {
- written = channel.write(buffer).get(writeTimeout, TimeUnit.MILLISECONDS);
+ written = channel.write(buffer).get(writeTimeout, TimeUnit.MILLISECONDS).intValue();
} catch (InterruptedException | ExecutionException
| TimeoutException e) {
onError(e);
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java Mon Mar 10 14:08:43 2014
@@ -199,6 +199,7 @@ public class Nio2Channel implements Asyn
}
};
+ @SuppressWarnings("unused")
public Future<Boolean> flush()
throws IOException {
return DONE;
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Mon Mar 10 14:08:43 2014
@@ -757,6 +757,7 @@ public class Nio2Endpoint extends Abstra
super(channel);
}
+ @Override
public void reset(Nio2Channel channel, long soTimeout) {
super.reset(channel, soTimeout);
upgradeInit = false;
@@ -794,6 +795,7 @@ public class Nio2Endpoint extends Abstra
long timeout = super.getTimeout();
return (timeout > 0) ? timeout : Long.MAX_VALUE;
}
+ @Override
public void setUpgraded(boolean upgraded) {
if (upgraded && !isUpgraded()) {
upgradeInit = true;
@@ -911,7 +913,7 @@ public class Nio2Endpoint extends Abstra
@Override
public synchronized void completed(Integer nBytes, SocketWrapper<Nio2Channel> attachment) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
failed(new ClosedChannelException(), attachment);
return;
}
@@ -983,13 +985,18 @@ public class Nio2Endpoint extends Abstra
// If not using SSL and direct buffers are not used, the
// idea of sendfile is to avoid memory copies, so allocate a
// direct buffer
- int BUFFER_SIZE;
+ int bufferSize;
try {
- BUFFER_SIZE = socket.getSocket().getIOChannel().getOption(StandardSocketOptions.SO_SNDBUF);
+ Integer bufferSizeInteger = socket.getSocket().getIOChannel().getOption(StandardSocketOptions.SO_SNDBUF);
+ if (bufferSizeInteger != null) {
+ bufferSize = bufferSizeInteger.intValue();
+ } else {
+ bufferSize = 8192;
+ }
} catch (IOException e) {
- BUFFER_SIZE = 8192;
+ bufferSize = 8192;
}
- buffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
+ buffer = ByteBuffer.allocateDirect(bufferSize);
} else {
buffer = socket.getSocket().getBufHandler().getWriteBuffer();
}
@@ -1008,7 +1015,7 @@ public class Nio2Endpoint extends Abstra
@Override
public void completed(Integer nw, SendfileData attachment) {
- if (nw < 0) { // Reach the end of stream
+ if (nw.intValue() < 0) { // Reach the end of stream
closeSocket(socket, SocketStatus.DISCONNECT);
try {
attachment.fchannel.close();
@@ -1018,8 +1025,8 @@ public class Nio2Endpoint extends Abstra
return;
}
- attachment.pos += nw;
- attachment.length -= nw;
+ attachment.pos += nw.intValue();
+ attachment.length -= nw.intValue();
if (attachment.length <= 0) {
socket.setSendfileData(null);
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Mon Mar 10 14:08:43 2014
@@ -70,7 +70,7 @@ public class SecureNio2Channel extends N
handshakeReadCompletionHandler = new CompletionHandler<Integer, SocketWrapper<Nio2Channel>>() {
@Override
public void completed(Integer result, SocketWrapper<Nio2Channel> attachment) {
- if (result < 0) {
+ if (result.intValue() < 0) {
failed(new IOException("Error"), attachment);
return;
}
@@ -84,7 +84,7 @@ public class SecureNio2Channel extends N
handshakeWriteCompletionHandler = new CompletionHandler<Integer, SocketWrapper<Nio2Channel>>() {
@Override
public void completed(Integer result, SocketWrapper<Nio2Channel> attachment) {
- if (result < 0) {
+ if (result.intValue() < 0) {
failed(new IOException("Error"), attachment);
return;
}
@@ -157,17 +157,17 @@ public class SecureNio2Channel extends N
@Override
public Boolean get() throws InterruptedException,
ExecutionException {
- int result = integer.get();
- return result >= 0;
+ int result = integer.get().intValue();
+ return Boolean.valueOf(result >= 0);
}
@Override
public Boolean get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException,
TimeoutException {
- int result = integer.get(timeout, unit);
- return result >= 0;
+ int result = integer.get(timeout, unit).intValue();
+ return Boolean.valueOf(result >= 0);
}
- };
+ }
/**
* Flush the channel.
@@ -408,7 +408,7 @@ public class SecureNio2Channel extends N
sslEngine.closeOutbound();
try {
- if (!flush().get(endpoint.getSoTimeout(), TimeUnit.MILLISECONDS)) {
+ if (!flush().get(endpoint.getSoTimeout(), TimeUnit.MILLISECONDS).booleanValue()) {
throw new IOException("Remaining data in the network buffer, can't send SSL close message, force a close with close(true) instead");
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
@@ -474,10 +474,10 @@ public class SecureNio2Channel extends N
protected Integer unwrap(int netread) throws ExecutionException {
//are we in the middle of closing or closed?
if (closing || closed)
- return -1;
+ return Integer.valueOf(-1);
//did we reach EOF? if so send EOF up one layer.
if (netread == -1)
- return -1;
+ return Integer.valueOf(-1);
//the data read
int read = 0;
//the SSL engine result
@@ -513,7 +513,7 @@ public class SecureNio2Channel extends N
throw new ExecutionException(new IOException("Unable to unwrap data, invalid status: " + unwrap.getStatus()));
}
} while ((netInBuffer.position() != 0)); //continue to unwrapping as long as the input buffer has stuff
- return (read);
+ return Integer.valueOf(read);
}
}
@@ -536,14 +536,14 @@ public class SecureNio2Channel extends N
}
@Override
public Integer get() throws InterruptedException, ExecutionException {
- int netread = integer.get();
+ int netread = integer.get().intValue();
return unwrap(netread);
}
@Override
public Integer get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException,
TimeoutException {
- int netread = integer.get(timeout, unit);
+ int netread = integer.get(timeout, unit).intValue();
return unwrap(netread);
}
}
@@ -613,7 +613,7 @@ public class SecureNio2Channel extends N
throw new ExecutionException(t);
}
integer.get();
- return written;
+ return Integer.valueOf(written);
}
@Override
public Integer get(long timeout, TimeUnit unit)
@@ -623,7 +623,7 @@ public class SecureNio2Channel extends N
throw new ExecutionException(t);
}
integer.get(timeout, unit);
- return written;
+ return Integer.valueOf(written);
}
}
@@ -649,7 +649,7 @@ public class SecureNio2Channel extends N
@Override
public void completed(Integer nBytes, A attach) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
handler.failed(new ClosedChannelException(), attach);
return;
}
@@ -686,7 +686,7 @@ public class SecureNio2Channel extends N
}
} while ((netInBuffer.position() != 0)); //continue to unwrapping as long as the input buffer has stuff
// If everything is OK, so complete
- handler.completed(read, attach);
+ handler.completed(Integer.valueOf(read), attach);
} catch (Exception e) {
// The operation must fails
handler.failed(e, attach);
@@ -704,15 +704,15 @@ public class SecureNio2Channel extends N
final CompletionHandler<Integer, ? super A> handler) {
//are we in the middle of closing or closed?
if (closing || closed) {
- handler.completed(-1, attachment);
+ handler.completed(Integer.valueOf(-1), attachment);
return;
}
//did we finish our handshake?
if (!handshakeComplete)
throw new IllegalStateException("Handshake incomplete, you must complete handshake before reading data.");
- ReadCompletionHandler<A> readCompletionHandler = new ReadCompletionHandler<A>(dst, handler);
+ ReadCompletionHandler<A> readCompletionHandler = new ReadCompletionHandler<>(dst, handler);
if (netInBuffer.position() > 0 ) {
- readCompletionHandler.completed(netInBuffer.position(), attachment);
+ readCompletionHandler.completed(Integer.valueOf(netInBuffer.position()), attachment);
} else {
sc.read(netInBuffer, timeout, unit, attachment, readCompletionHandler);
}
@@ -746,12 +746,12 @@ public class SecureNio2Channel extends N
new CompletionHandler<Integer, A>() {
@Override
public void completed(Integer nBytes, A attach) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
handler.failed(new ClosedChannelException(), attach);
} else {
// Call the handler completed method with the
// consumed bytes number
- handler.completed(written, attach);
+ handler.completed(Integer.valueOf(written), attach);
}
}
@Override
@@ -795,11 +795,11 @@ public class SecureNio2Channel extends N
}
@Override
public void completed(Integer nBytes, GatherState<A> attachment) {
- if (nBytes < 0) {
+ if (nBytes.intValue() < 0) {
state.handler.failed(new ClosedChannelException(), state.attachment);
} else {
if (state.pos == state.offset + state.length) {
- state.handler.completed(state.writeCount, state.attachment);
+ state.handler.completed(Long.valueOf(state.writeCount), state.attachment);
return;
}
try {
@@ -859,7 +859,7 @@ public class SecureNio2Channel extends N
return;
}
// Write data to the channel
- sc.write(netOutBuffer, timeout, unit, state, new GatherCompletionHandler<A>(state));
+ sc.write(netOutBuffer, timeout, unit, state, new GatherCompletionHandler<>(state));
} catch (Throwable exp) {
handler.failed(exp, attachment);
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java?rev=1575946&r1=1575945&r2=1575946&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java Mon Mar 10 14:08:43 2014
@@ -218,24 +218,24 @@ public class SocketProperties {
public void setProperties(AsynchronousSocketChannel socket) throws IOException {
if (rxBufSize != null)
- socket.setOption(StandardSocketOptions.SO_RCVBUF, rxBufSize.intValue());
+ socket.setOption(StandardSocketOptions.SO_RCVBUF, rxBufSize);
if (txBufSize != null)
- socket.setOption(StandardSocketOptions.SO_SNDBUF, txBufSize.intValue());
+ socket.setOption(StandardSocketOptions.SO_SNDBUF, txBufSize);
if (soKeepAlive != null)
- socket.setOption(StandardSocketOptions.SO_KEEPALIVE, soKeepAlive.booleanValue());
+ socket.setOption(StandardSocketOptions.SO_KEEPALIVE, soKeepAlive);
if (soReuseAddress != null)
- socket.setOption(StandardSocketOptions.SO_REUSEADDR, soReuseAddress.booleanValue());
+ socket.setOption(StandardSocketOptions.SO_REUSEADDR, soReuseAddress);
if (soLingerOn != null && soLingerOn.booleanValue() && soLingerTime != null)
- socket.setOption(StandardSocketOptions.SO_LINGER, soLingerTime.intValue());
+ socket.setOption(StandardSocketOptions.SO_LINGER, soLingerTime);
if (tcpNoDelay != null)
- socket.setOption(StandardSocketOptions.TCP_NODELAY, tcpNoDelay.booleanValue());
+ socket.setOption(StandardSocketOptions.TCP_NODELAY, tcpNoDelay);
}
public void setProperties(AsynchronousServerSocketChannel socket) throws IOException {
if (rxBufSize != null)
- socket.setOption(StandardSocketOptions.SO_RCVBUF, rxBufSize.intValue());
+ socket.setOption(StandardSocketOptions.SO_RCVBUF, rxBufSize);
if (soReuseAddress != null)
- socket.setOption(StandardSocketOptions.SO_REUSEADDR, soReuseAddress.booleanValue());
+ socket.setOption(StandardSocketOptions.SO_REUSEADDR, soReuseAddress);
}
public boolean getDirectBuffer() {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org