[Bug 58143] The WebppClassLoader doesn't call transformers on cached classes

2018-01-28 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=58143

Rainer Jung  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #10 from Rainer Jung  ---
Reopening this for TC 7.

My situation:

- not using Springs TomcatInstrumentableClassLoader  but instead relying on the
normal Tomcat WebappClassLoader (and WebappClassLoaderBase) implementing
InstrumentableClassLoader

- using Spring load time weaving

That combination works starting with the implementation of
InstrumentableClassLoader in 7.0.64 but is broken again since 7.0.70.

Reason is the reorganization of the resourceEntries cache. During context
initialization the class which should get woven is loaded two times. Once as a
resource (and at a time when the weaver was not yet added to the class loader)
and then again as a class with the weaver in place. Starting with 7.0.70 the
loading as a resource and as a class use the same key in the resourceEntries
cache. Since the weaving does not happen when a class is served from the cache,
this breaks it.

In TC 8, 8.5 and 9 there was a later change in WebappClassLoaderBase which
makes it work again. The weaving was moved from close to the place were
resources get added to resourceEntries in findResourceInternal() to
findClassInternal().

That change also does quite a few other things, so I isolated it moving the
weaver call and tested it in TC 7 with the unit tests. This did not show any
problems.

Originally the problem was observed using Spring 3.0, but the behavior is
unchanged for at least of Spring 3.0-4.3.9.

I will attach a suggested patch and also a simple example webapp named "weave".
Calling the URI /weave/ will respond with "Hello World!" if weaving succeeds,
and with "Unwoven" if not. See the trivial class Greeting, the beans file
weave.xml, its declaration in web.xml and the index.jsp, all of which are very
small. Unfortunately the war file is 6 MB due to the size of the included
Spring jar files.

Regards,

Rainer

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 58143] The WebppClassLoader doesn't call transformers on cached classes

2018-01-28 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=58143

--- Comment #11 from Rainer Jung  ---
Created attachment 35700
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35700&action=edit
Suggested patch for TC 7

Minimal patch for TC 7

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 58143] The WebppClassLoader doesn't call transformers on cached classes

2018-01-28 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=58143

--- Comment #12 from Rainer Jung  ---
The fix for trunk, which was backported to 8.5 and 8 but not to seven was:

r1730946 | markt | 2016-02-17 22:16:40 +0100 (Wed, 17 Feb 2016) | 1 line

Refactor class loading so JAR scanning does not trigger the caching of the
byte[] for every scanned class until the class is loaded.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 58143] The WebppClassLoader doesn't call transformers on cached classes

2018-01-28 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=58143

--- Comment #13 from Rainer Jung  ---
The example webapp is available at

https://gist.github.com/rainerjung/99802d9cf321b9c594665b2933d8ea49

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 58143] The WebppClassLoader doesn't call transformers on cached classes

2018-01-28 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=58143

--- Comment #14 from Rainer Jung  ---
Finally for the sake of completeness the stacks of the two loading calls for
the class to get woven.

First call (happening before Spring called addTransformer()). Here
name="de/kippdata/demo/weave/Greeting.class",
path="/de/kippdata/demo/weave/Greeting.class", so the class was loaded as a
resource:

at
org.apache.catalina.loader.WebappClassLoaderBase.findResourceInternal(WebappClassLoaderBase.java:3194)
at
org.apache.catalina.loader.WebappClassLoaderBase.findResource(WebappClassLoaderBase.java:1473)
at
org.apache.catalina.loader.WebappClassLoaderBase.getResourceAsStream(WebappClassLoaderBase.java:1701)
at
org.springframework.core.OverridingClassLoader.openStreamForClass(OverridingClassLoader.java:166)
at
org.springframework.core.OverridingClassLoader.loadBytesForClass(OverridingClassLoader.java:142)
at
org.springframework.context.support.ContextTypeMatchClassLoader$ContextOverridingClassLoader.loadClassForOverriding(ContextTypeMatchClassLoader.java:111)
at
org.springframework.core.OverridingClassLoader.loadClass(OverridingClassLoader.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at
org.springframework.core.OverridingClassLoader.loadClass(OverridingClassLoader.java:84)
at
org.springframework.context.support.ContextTypeMatchClassLoader.loadClass(ContextTypeMatchClassLoader.java:72)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1429)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1377)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:641)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:425)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395)
at
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:81)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5109)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5632)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)
at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:2020)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)


Second call, now with transformers in place but with class already cached. Here
name="de.kippdata.demo.weave.Greeting",
path="/de/kippdata/demo/weave/Greeting.class", so the class was loaded as an
actual class:

at
org.apache.catalina.loader.WebappClassLoaderBase.findResourceInternal(WebappClassLoaderBase.java:3194)
at
org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3060)
at
org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1388)
at
org.apache.catalina

svn commit: r1822478 - /tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java

2018-01-28 Thread markt
Author: markt
Date: Sun Jan 28 20:54:47 2018
New Revision: 1822478

URL: http://svn.apache.org/viewvc?rev=1822478&view=rev
Log:
Code clean-up. No functional change.

Modified:
tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java?rev=1822478&r1=1822477&r2=1822478&view=diff
==
--- tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java Sun Jan 28 
20:54:47 2018
@@ -87,7 +87,7 @@ public final class MessageBytes implemen
 }
 
 public boolean isNull() {
-return byteC.isNull() && charC.isNull() && ! hasStrValue;
+return byteC.isNull() && charC.isNull() && !hasStrValue;
 }
 
 /**
@@ -161,18 +161,18 @@ public final class MessageBytes implemen
  */
 @Override
 public String toString() {
-if( hasStrValue ) {
+if (hasStrValue) {
 return strValue;
 }
 
 switch (type) {
 case T_CHARS:
-strValue=charC.toString();
-hasStrValue=true;
+strValue = charC.toString();
+hasStrValue = true;
 return strValue;
 case T_BYTES:
-strValue=byteC.toString();
-hasStrValue=true;
+strValue = byteC.toString();
+hasStrValue = true;
 return strValue;
 }
 return null;
@@ -235,11 +235,11 @@ public final class MessageBytes implemen
  */
 public void toBytes() {
 if (!byteC.isNull()) {
-type=T_BYTES;
+type = T_BYTES;
 return;
 }
 toString();
-type=T_BYTES;
+type = T_BYTES;
 Charset charset = byteC.getCharset();
 ByteBuffer result = charset.encode(strValue);
 byteC.setBytes(result.array(), result.arrayOffset(), result.limit());
@@ -250,14 +250,14 @@ public final class MessageBytes implemen
  * XXX Not optimized - it converts to String first.
  */
 public void toChars() {
-if( ! charC.isNull() ) {
-type=T_CHARS;
+if (!charC.isNull()) {
+type = T_CHARS;
 return;
 }
 // inefficient
 toString();
-type=T_CHARS;
-char cc[]=strValue.toCharArray();
+type = T_CHARS;
+char cc[] = strValue.toCharArray();
 charC.setChars(cc, 0, cc.length);
 }
 



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



buildbot success in on tomcat-trunk

2018-01-28 Thread buildbot
The Buildbot has detected a restored build on builder tomcat-trunk while 
building . Full details are available at:
https://ci.apache.org/builders/tomcat-trunk/builds/2996

Buildbot URL: https://ci.apache.org/

Buildslave for this Build: silvanus_ubuntu

Build Reason: The AnyBranchScheduler scheduler named 'on-tomcat-commit' 
triggered this build
Build Source Stamp: [branch tomcat/trunk] 1822478
Blamelist: markt

Build succeeded!

Sincerely,
 -The Buildbot




-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



svn commit: r1822482 - in /tomcat/trunk: java/org/apache/tomcat/util/buf/ test/org/apache/tomcat/util/buf/ test/org/apache/tomcat/util/net/ webapps/docs/

2018-01-28 Thread markt
Author: markt
Date: Sun Jan 28 21:33:53 2018
New Revision: 1822482

URL: http://svn.apache.org/viewvc?rev=1822482&view=rev
Log:
Ensure that the toString() method behaves consistently for ByteChunk and 
CharChunk and that null is returned when toString() is called both on newly 
created objects and immediately after a call to recycle().
This should not impact typical Tomcat users.
It may impact users who use these classes directly in their own code.

Modified:
tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java
tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java
tomcat/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java
tomcat/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java
tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java
tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java?rev=1822482&r1=1822481&r2=1822482&view=diff
==
--- tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java Sun Jan 28 
21:33:53 2018
@@ -529,7 +529,7 @@ public final class ByteChunk extends Abs
 
 @Override
 public String toString() {
-if (null == buff) {
+if (isNull()) {
 return null;
 } else if (end - start == 0) {
 return "";

Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java?rev=1822482&r1=1822481&r2=1822482&view=diff
==
--- tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java Sun Jan 28 
21:33:53 2018
@@ -396,7 +396,7 @@ public final class CharChunk extends Abs
 
 @Override
 public String toString() {
-if (null == buff) {
+if (isNull()) {
 return null;
 } else if (end - start == 0) {
 return "";

Modified: tomcat/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java?rev=1822482&r1=1822481&r2=1822482&view=diff
==
--- tomcat/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java Sun Jan 28 
21:33:53 2018
@@ -201,4 +201,18 @@ public class TestByteChunk {
 // NO-OP
 }
 }
+
+
+@Test
+public void testToString() {
+ByteChunk bc = new ByteChunk();
+Assert.assertNull(bc.toString());
+byte[] data = new byte[8];
+bc.setBytes(data, 0, data.length);
+Assert.assertNotNull(bc.toString());
+bc.recycle();
+// toString() should behave consistently for new ByteChunk and
+// immediately after a call to recycle().
+Assert.assertNull(bc.toString());
+}
 }

Modified: tomcat/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java?rev=1822482&r1=1822481&r2=1822482&view=diff
==
--- tomcat/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java Sun Jan 28 
21:33:53 2018
@@ -93,4 +93,19 @@ public class TestCharChunk {
 // NO-OP
 }
 }
+
+
+@Test
+public void testToString() {
+CharChunk cc = new CharChunk();
+Assert.assertNull(cc.toString());
+char[] data = new char[8];
+cc.setChars(data, 0, data.length);
+Assert.assertNotNull(cc.toString());
+cc.recycle();
+// toString() should behave consistently for new ByteChunk and
+// immediately after a call to recycle().
+Assert.assertNull(cc.toString());
+}
+
 }

Modified: tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java?rev=1822482&r1=1822481&r2=1822482&view=diff
==
--- tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java Sun Jan 28 
21:33:53 2018
@@ -172,7 +172,7 @@ public class TestCustomSsl extends Tomca
 
 if (trustType.equals(TrustType.NONE)) {
 Assert.assertTrue(rc != 200);
-Assert.assertEquals("", res.toString());
+Assert.assertNu

[Bug 62052] New: upgrade HTTP/2 can't use gzip compress

2018-01-28 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=62052

Bug ID: 62052
   Summary: upgrade HTTP/2 can't use gzip compress
   Product: Tomcat 8
   Version: 8.5.27
  Hardware: PC
Status: NEW
  Severity: normal
  Priority: P2
 Component: Connectors
  Assignee: dev@tomcat.apache.org
  Reporter: pc8...@gmail.com
  Target Milestone: 

Original from Bug #60276 https://bz.apache.org/bugzilla/show_bug.cgi?id=60276

Using tomcat 8.5.27, this problem is still not fixed.

Removed 
and gzip works again.








-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org