[tomcat] branch master updated: Cleanup code using the new tool release
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/master by this push: new 9747a3a Cleanup code using the new tool release 9747a3a is described below commit 9747a3a6334369deb9b5bef1b17b1fe0ce774cdf Author: remm AuthorDate: Mon May 10 09:13:54 2021 +0200 Cleanup code using the new tool release Also log when an unknown profile is specified. --- java/org/apache/catalina/loader/LocalStrings.properties | 1 + java/org/apache/catalina/loader/WebappLoader.java | 17 ++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/java/org/apache/catalina/loader/LocalStrings.properties b/java/org/apache/catalina/loader/LocalStrings.properties index 7c6c976..521c90f 100644 --- a/java/org/apache/catalina/loader/LocalStrings.properties +++ b/java/org/apache/catalina/loader/LocalStrings.properties @@ -67,3 +67,4 @@ webappLoader.starting=Starting this Loader webappLoader.stopError=Error stopping the loader webappLoader.stopping=Stopping this Loader webappLoader.unknownClassLoader=Unknown class loader [{0}] of class [{1}] +webappLoader.unknownProfile=Unknown Jakarta profile [{0}] specified, the default profile will be used instead diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java index a9d5ccc..5015b93 100644 --- a/java/org/apache/catalina/loader/WebappLoader.java +++ b/java/org/apache/catalina/loader/WebappLoader.java @@ -21,9 +21,7 @@ import java.beans.PropertyChangeSupport; import java.io.File; import java.io.FilePermission; import java.io.IOException; -import java.lang.instrument.ClassFileTransformer; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.net.URLClassLoader; import java.nio.charset.StandardCharsets; @@ -367,17 +365,14 @@ public class WebappLoader extends LifecycleMBeanBase implements Loader{ // Set Jakarta class converter if (getJakartaConverter() != null) { -ClassFileTransformer transformer = null; +EESpecProfile profile = null; try { -EESpecProfile profile = EESpecProfile.valueOf(getJakartaConverter()); -transformer = ClassConverter.class.getConstructor(EESpecProfile.class).newInstance(profile); -// FIXME: after Migration 0.3 -//transformer = new ClassConverter(EESpecProfile.valueOf(getJakartaConverter())); -} catch (InvocationTargetException | NoSuchMethodException | IllegalArgumentException ignored) { -// Use default value with no argument constructor -transformer = new ClassConverter(); +profile = EESpecProfile.valueOf(getJakartaConverter()); +} catch (IllegalArgumentException ignored) { +// Use default value +log.warn(sm.getString("webappLoader.unknownProfile", getJakartaConverter())); } -classLoader.addTransformer(transformer); +classLoader.addTransformer((profile != null) ? new ClassConverter(profile) : new ClassConverter()); } // Configure our repositories - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch master updated: Cleanup destination temp before migration
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/master by this push: new ed63c95 Cleanup destination temp before migration ed63c95 is described below commit ed63c95e4ca5ca88855416561a1dcce05fd27081 Author: remm AuthorDate: Fri Feb 19 15:46:07 2021 +0100 Cleanup destination temp before migration createTempFile creates a file, so it is not compatible with a directory migration. The first thing I tried was a migration of the examples webapp and it didn't work since this is an exploded folder. --- java/org/apache/catalina/startup/HostConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/org/apache/catalina/startup/HostConfig.java b/java/org/apache/catalina/startup/HostConfig.java index 1aac2df..4cc8b5e 100644 --- a/java/org/apache/catalina/startup/HostConfig.java +++ b/java/org/apache/catalina/startup/HostConfig.java @@ -1281,6 +1281,8 @@ public class HostConfig implements LifecycleListener { try { tempNew = File.createTempFile("new", null, host.getLegacyAppBaseFile()); tempOld = File.createTempFile("old", null, host.getLegacyAppBaseFile()); +// createTempFile is not directly compatible with directories, so cleanup +ExpandWar.delete(tempNew); // The use of defaults is deliberate here to avoid having to // recreate every configuration option on the host. Better to change - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch master updated: Cleanup the preface read code
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/master by this push: new f1cf343 Cleanup the preface read code f1cf343 is described below commit f1cf343959ee40b245db463a055b7363a41fc202 Author: remm AuthorDate: Tue Apr 30 11:53:07 2019 +0200 Cleanup the preface read code Try to reduce code duplication. I'll then look if I can reproduce the #4263 failures if they occur again. --- java/org/apache/coyote/http2/Http2AsyncParser.java | 145 - 1 file changed, 82 insertions(+), 63 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java b/java/org/apache/coyote/http2/Http2AsyncParser.java index b00c092..3cf6d1b 100644 --- a/java/org/apache/coyote/http2/Http2AsyncParser.java +++ b/java/org/apache/coyote/http2/Http2AsyncParser.java @@ -47,74 +47,90 @@ class Http2AsyncParser extends Http2Parser { @Override void readConnectionPreface(WebConnection webConnection, Stream stream) throws Http2Exception { -byte[] data = new byte[CLIENT_PREFACE_START.length]; +byte[] prefaceData = new byte[CLIENT_PREFACE_START.length]; +ByteBuffer preface = ByteBuffer.wrap(prefaceData); +ByteBuffer header = ByteBuffer.allocate(9); +ByteBuffer framePaylod = ByteBuffer.allocate(input.getMaxFrameSize()); +PrefaceCompletionHandler handler = new PrefaceCompletionHandler(webConnection, stream, prefaceData, preface, header, framePaylod); socketWrapper.read(BlockingMode.NON_BLOCK, socketWrapper.getReadTimeout(), TimeUnit.MILLISECONDS, null, -SocketWrapperBase.COMPLETE_READ_WITH_COMPLETION, new CompletionHandler() { -@Override -public void completed(Long result, Void attachment) { +handler, handler, preface, header, framePaylod); +} + + +private class PrefaceCompletionHandler extends FrameCompletionHandler { + +private boolean prefaceValidated = false; + +private final WebConnection webConnection; +private final Stream stream; +private final byte[] prefaceData; + +private PrefaceCompletionHandler(WebConnection webConnection, Stream stream, byte[] prefaceData, ByteBuffer... buffers) { +super(FrameType.SETTINGS, buffers); +this.webConnection = webConnection; +this.stream = stream; +this.prefaceData = prefaceData; +} + +@Override +public CompletionHandlerCall callHandler(CompletionState state, ByteBuffer[] buffers, int offset, int length) { +if (offset != 0 || length != 3) { +try { +throw new IllegalArgumentException(sm.getString("http2Parser.invalidBuffers")); +} catch (IllegalArgumentException e) { +error = e; +return CompletionHandlerCall.DONE; +} +} +if (!prefaceValidated) { +if (buffers[0].hasRemaining()) { +// The preface must be fully read before being validated +return CompletionHandlerCall.CONTINUE; +} +// Validate preface content for (int i = 0; i < CLIENT_PREFACE_START.length; i++) { -if (CLIENT_PREFACE_START[i] != data[i]) { -failed(new ProtocolException(sm.getString("http2Parser.preface.invalid")), null); -return; +if (CLIENT_PREFACE_START[i] != prefaceData[i]) { +error = new ProtocolException(sm.getString("http2Parser.preface.invalid")); +return CompletionHandlerCall.DONE; } } -// Must always be followed by a settings frame +prefaceValidated = true; +} +return validate(state, buffers[1], buffers[2]); +} + +@Override +public void completed(Long result, Void attachment) { +if (streamException || error == null) { +ByteBuffer payload = buffers[2]; +payload.flip(); try { -ByteBuffer header = ByteBuffer.allocate(9); -ByteBuffer framePaylod = ByteBuffer.allocate(input.getMaxFrameSize()); -FrameCompletionHandler handler = new FrameCompletionHandler(FrameType.SETTINGS, header, framePaylod) { -@Override -public void completed(Long result, Void attachment) { -if (streamException || error == null) { -ByteBuffer payload = buffers[1]; -payload.flip(); -try { -
[tomcat] branch master updated: Cleanup
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/master by this push: new 2eb64d1 Cleanup 2eb64d1 is described below commit 2eb64d1d18196b1ada18b6d435055b7d93c4f7ce Author: remm AuthorDate: Tue Apr 30 10:41:48 2019 +0200 Cleanup Add two utility read completion checks. Actually, the code is the same as for write. Also use hasRemaining. --- java/org/apache/tomcat/util/net/SocketWrapperBase.java | 18 -- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/java/org/apache/tomcat/util/net/SocketWrapperBase.java b/java/org/apache/tomcat/util/net/SocketWrapperBase.java index ea14e2c..cd2e619 100644 --- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java +++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java @@ -892,7 +892,7 @@ public abstract class SocketWrapperBase { public CompletionHandlerCall callHandler(CompletionState state, ByteBuffer[] buffers, int offset, int length) { for (int i = 0; i < length; i++) { -if (buffers[offset + i].remaining() > 0) { +if (buffers[offset + i].hasRemaining()) { return CompletionHandlerCall.CONTINUE; } } @@ -910,7 +910,7 @@ public abstract class SocketWrapperBase { public CompletionHandlerCall callHandler(CompletionState state, ByteBuffer[] buffers, int offset, int length) { for (int i = 0; i < length; i++) { -if (buffers[offset + i].remaining() > 0) { +if (buffers[offset + i].hasRemaining()) { return CompletionHandlerCall.CONTINUE; } } @@ -933,6 +933,20 @@ public abstract class SocketWrapperBase { }; /** + * This utility CompletionCheck will cause the completion handler + * to be called once the given buffers are full. The completion + * handler will then be called. + */ +public static final CompletionCheck COMPLETE_READ_WITH_COMPLETION = COMPLETE_WRITE_WITH_COMPLETION; + +/** + * This utility CompletionCheck will cause the completion handler + * to be called once the given buffers are full. If the operation + * completes inline, the completion handler will not be called. + */ +public static final CompletionCheck COMPLETE_READ = COMPLETE_WRITE; + +/** * Allows using NIO2 style read/write only for connectors that can * efficiently support it. * - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch master updated: Cleanup
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/master by this push: new f11449d Cleanup f11449d is described below commit f11449d9ebb09c5bb5c5571b413b29475c8a9fd6 Author: remm AuthorDate: Tue Apr 23 13:50:48 2019 +0200 Cleanup It seems the Registry constructor could be protected since getRegistry should be used instead. --- java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java | 2 +- java/org/apache/tomcat/util/modeler/Registry.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java b/java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java index ef7d341..33c5d97 100644 --- a/java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java +++ b/java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java @@ -44,7 +44,7 @@ import javax.management.QueryExp; import javax.management.ReflectionException; import javax.management.loading.ClassLoaderRepository; -/* +/** * An implementation of the MBean registry that effectively disables MBean * registration. This is typically used when low memory footprint is a primary * concern. diff --git a/java/org/apache/tomcat/util/modeler/Registry.java b/java/org/apache/tomcat/util/modeler/Registry.java index 5a66a0f..0958a92 100644 --- a/java/org/apache/tomcat/util/modeler/Registry.java +++ b/java/org/apache/tomcat/util/modeler/Registry.java @@ -114,7 +114,7 @@ public class Registry implements RegistryMBean, MBeanRegistration { // --- Constructors -public Registry() { +protected Registry() { super(); } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch master updated: Cleanup according to current object names, no change
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/master by this push: new 9b91bc7 Cleanup according to current object names, no change 9b91bc7 is described below commit 9b91bc78a5492c21709b840f8b4ad8030d3fb2f4 Author: remm AuthorDate: Mon Apr 15 23:40:54 2019 +0200 Cleanup according to current object names, no change --- java/org/apache/tomcat/util/net/NioEndpoint.java | 43 +--- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 97bd44a..7a9e708 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -676,24 +676,27 @@ public class NioEndpoint extends AbstractJsseEndpoint addEvent(r); } -public NioSocketWrapper cancelledKey(SelectionKey key) { -NioSocketWrapper ka = null; +public NioSocketWrapper cancelledKey(SelectionKey sk) { +NioSocketWrapper socketWrapper = null; try { -if ( key == null ) return null;//nothing to do -ka = (NioSocketWrapper) key.attach(null); -if (ka != null) { +if (sk == null) { +// Nothing to do +return null; +} +socketWrapper = (NioSocketWrapper) sk.attach(null); +if (socketWrapper != null) { // If attachment is non-null then there may be a current // connection with an associated processor. -getHandler().release(ka); +getHandler().release(socketWrapper); } -if (key.isValid()) key.cancel(); +if (sk.isValid()) sk.cancel(); // If it is available, close the NioChannel first which should // in turn close the underlying SocketChannel. The NioChannel // needs to be closed first, if available, to ensure that TLS // connections are shut down cleanly. -if (ka != null) { +if (socketWrapper != null) { try { -ka.getSocket().close(true); +socketWrapper.getSocket().close(true); } catch (Exception e){ if (log.isDebugEnabled()) { log.debug(sm.getString( @@ -703,9 +706,9 @@ public class NioEndpoint extends AbstractJsseEndpoint } // The SocketChannel is also available via the SelectionKey. If // it hasn't been closed in the block above, close it now. -if (key.channel().isOpen()) { +if (sk.channel().isOpen()) { try { -key.channel().close(); +sk.channel().close(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug(sm.getString( @@ -714,22 +717,24 @@ public class NioEndpoint extends AbstractJsseEndpoint } } try { -if (ka != null && ka.getSendfileData() != null -&& ka.getSendfileData().fchannel != null -&& ka.getSendfileData().fchannel.isOpen()) { -ka.getSendfileData().fchannel.close(); +if (socketWrapper != null && socketWrapper.getSendfileData() != null +&& socketWrapper.getSendfileData().fchannel != null +&& socketWrapper.getSendfileData().fchannel.isOpen()) { +socketWrapper.getSendfileData().fchannel.close(); } } catch (Exception ignore) { } -if (ka != null) { +if (socketWrapper != null) { countDownConnection(); -ka.closed = true; +socketWrapper.closed = true; } } catch (Throwable e) { ExceptionUtils.handleThrowable(e); -if (log.isDebugEnabled()) log.error("",e); +if (log.isDebugEnabled()) { +log.error("", e); +} } -return ka; +return socketWrapper; } /** - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch master updated: Cleanup, no functional change
This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/master by this push: new 52c3d1b Cleanup, no functional change 52c3d1b is described below commit 52c3d1ba2b0c5b96ddf923bd0d563a7d89051fed Author: remm AuthorDate: Tue Mar 26 00:23:30 2019 +0100 Cleanup, no functional change --- java/org/apache/tomcat/util/net/Nio2Endpoint.java | 50 --- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java index ea4a8ef..c58aac9 100644 --- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java +++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java @@ -915,13 +915,6 @@ public class Nio2Endpoint extends AbstractJsseEndpoint 0) { -// Special case where the read completes inline, there is no notification -// in that case and it cannot happen elsewhere - getEndpoint().processSocket(Nio2SocketWrapper.this, SocketEvent.OPEN_READ, true); +// Special case where the read completed inline, there is no notification +// in that case so it has to be done here +getEndpoint().processSocket(this, SocketEvent.OPEN_READ, true); } } catch (IOException e) { // Will never happen @@ -1511,7 +1495,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint