Bug 55155 - running tomcat tests cause terminal to repeatedly grab focus (on os x)
running tomcat tests cause terminal to repeatedly grab focus (on os x)
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Packaging
unspecified
Macintosh Mac OS X 10.4
: P2 minor (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-06-28 14:38 UTC by Casey Lucas
Modified: 2013-07-01 14:05 UTC (History)
0 users



Attachments
patch to add java.awt.headless=true for junit tests (432 bytes, text/plain)
2013-06-28 14:38 UTC, Casey Lucas
Details
against head? (432 bytes, patch)
2013-06-28 15:27 UTC, Casey Lucas
Details | Diff
set apple.awt.UIElement=true (434 bytes, patch)
2013-06-28 20:00 UTC, Casey Lucas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Casey Lucas 2013-06-28 14:38:52 UTC
Created attachment 30493 [details]
patch to add java.awt.headless=true for junit tests

On osx, when running tomcat tests via "ant test", "ant test-nio" or similar, the terminal window running the tests grabs window focus each time a new jvm is launched for the junit tests.  This makes it difficult/annoying to do other things in other windows while the tests are running.  I am seeing the problem on a mac - it is likely not a problem on other platforms.

Setting java.awt.headless=true fixes the issue.  I can't think of any reason this shouldn't be set for tomcat tests - maybe there is a reason I don't know.  Anyway, the attached patch adds the property (for junit tests).
Comment 1 Mark Thomas 2013-06-28 15:09:14 UTC
Try again with 7.0.x HEAD please
Comment 2 Casey Lucas 2013-06-28 15:27:03 UTC
Created attachment 30494 [details]
against head?

is this what you wanted?  if not, please provide a tip or link.
Comment 3 Mark Thomas 2013-06-28 15:29:52 UTC
No, that isn't what I meant.

Please re-test with the latest source code for 7.0.x/trunk from subversion.
Comment 4 Mark Thomas 2013-06-28 18:26:32 UTC
I don;t see the described behaviour on OSX. This sounds like the AWT issue that has already been fixed in trunk. (change log entry: Update the JreMemoryLeakPreventionListener to take account of changes in the behaviour of java.beans.Introspector.flushCaches() and sun.awt.AppContext.getAppContext() in Java 7.)
Comment 5 Casey Lucas 2013-06-28 19:08:07 UTC
I ran the tests (again) after updating trunk. Same results (lots of window focus change). Are you trying the osx built-in Terminal app?  Maybe that has something to do with it.  I'm running tests under jdk6.  I'll try some more variations.
Comment 6 Mark Thomas 2013-06-28 19:36:14 UTC
OK, I do see it with Java 6. It would have helped if you mentioned that in your original report.
Comment 7 Casey Lucas 2013-06-28 19:59:51 UTC
Sorry for not mentioning the jdk version originally.  More digging revealed what I believe to be a better fix for the problem:

https://developer.apple.com/library/mac/#documentation/Java/Reference/Java_PropertiesRef/Articles/JavaSystemProperties.html  (See apple.awt.UIElement property.)

Setting it to true allows awt calls but does not steal focus. I'll add a new patch.
Comment 8 Casey Lucas 2013-06-28 20:00:56 UTC
Created attachment 30497 [details]
set apple.awt.UIElement=true
Comment 9 Mark Thomas 2013-07-01 14:05:09 UTC
I haven't dug into this far enough to idenitfy the trigger for this but it looks like whatever change triggered the probem in Java 7 has been back-ported to Java 6 but the change that allowed us to change the default for appContextProtection hasn't been back-ported.

I can't tell if this is an Apple specific issue or one that will affect anyone using the Oracle (commerical) supported Java 6 binaries.

An additional factor to take into consideration is the general reluctance of the Tomcat dev community to add work-arounds for bugs in third-party products (yes the JreMemoryLeakPreventionListener is a pretty big exception to that rule).

Given that OSX seems to be a fairly popular platform amongst Java developers then I think your second patch is the way to go for now. If this emerges as a wider Java 6 issue we can look at using java.awt.headless=true instead.

The patch has been applied to 7.0.x and will be included in 7.0.42 onwards.