Commit Graph

588 Commits

Author SHA1 Message Date
Greg Wilkins bde86467f4
Issue #3806 - Make Async sendError fully Async (#3912)
* Issue #3806 async sendError

Avoid using isHandled as a test withing sendError as this can be
called asynchronously and is in a race with the normal dispatch of the
request, which could also be setting handled status.

The ErrorHandler was dispatching directly to a context from within
sendError.  This meant that an async thread can call sendError and be
dispatched to within the servlet container at the same time that the
original thread was still dispatched to the container.

This commit fixes that problem by using an async dispatch for error
pages within the ErrorHandler.  However, this introduces a new problem
that a well behaved async app will call complete after calling
sendError.  Thus we have ignore complete ISEs for the remainder of
the current async cycle.

Fixed the closing of the output after calling sendError. Do not
close if the request was async (and thus might be dispatched to an
async error) or if it is now async because the error page itself is
async.

* updates from review
* better tests
* revert ignore complete
* added some TODOs
* more TODOs
* fixed rename
* cleanup ISE and more TODOs
* refactored to call sendError for uncaught exceptions rather than onError
* more of the refactor
* extra tests for sendError from completing state

Reworked HttpChannelState and sendError so that sendError is now
just a change of state. All the work is done in the ErrorDispatch
action, including calling the ErrorHandler.  Async not yet working.

Additional tests

Converted ERRORED state to a separate boolean so it can be used for
both Sync and Async dispatches.

Removed ASYNC_IO state as it was just the same as DISPATCHED

The async onError listener handling is now most likely broken.


WIP making sendError simpler and more tests pass
WIP handling async and thrown exceptions
WIP passing tests

Improved thread handling

removed bad test

Implemented error dispatch on complete properly
more fixed tests

sendError state looks committed

- Added resetContent method to leave more non-content headers during sendError
- Fixed security tests
- simplified the non dispatch error page writing.  Moved towards being able to write async

* fixed gzipHandlerTest

* Updated handling of timeout errors.  According to servlet spec,
exceptions thrown from onTimeout should not be passed to onError, but
just logged and ignored:

   If an exception is thrown while invoking methods in an AsyncListener,
   it is logged and will not affect the invocation of any other AsyncListeners.

* This changes several tests.

* Dispatcher/ContextHandler changes for new ERROR dispatch handling. Feels a bit fragile!

* Fixed tests in jetty-servlets
* Fixed tests in jetty-proxy

* more test fixes

* Fixed head handling
reverted unnecessary changes
Improved reason handling

WIP on fully async error handling.
Simplified HttpChannelState state machines to allow for async actions
during completing

more WIP on fully async error handling.

sendError and completion are not both non-blocking, without using
a startAsync operation. However we are lacking unit tests that actually
exercise those code paths.

* Simplified name of states
Added test for async completion
* Cleanups and javadoc
* Cleanups and javadoc
* remove snake case
* feedback from review
* Write error page into fixed pooled buffer

Use the response to get/release a pooled buffer into which the error
page can be written.  Make it a fixed sized buffer and if it overflows
then no error page is generated (first overflow turns off showstacks
to save space).

The ErrorHandler badly needs to be refactored, but we cannot change
API in jetty-9

* More test fixes for different error page format
* minor cleanups
* Cleanup from Review
* Fixed javadoc
* cleanups and simplifications
* Cleanup from Review
* renaming and some TODOs
* Cleanup from Review
* Checkstyle fixes
* Cleanup from Review
* Code cleanups and simplifications
* fixed debug
* Cleanup from Review
* Ensure response sent before server shutdown
* removed unnecessary optimisation
* fixed duplicate from merge
* Updates from review

Signed-off-by: Greg Wilkins <gregw@webtide.com>
2019-08-26 17:55:58 +10:00
Olivier Lamy fe3d3f7158
fix checkstyle in test sources (#4013)
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
2019-08-22 19:56:41 +10:00
Joakim Erdfelt f1efc99918 Updating to version 9.4.21-SNAPSHOT 2019-08-13 17:34:20 -05:00
Joakim Erdfelt 84700530e6 Updating to version 9.4.20.v20190813 2019-08-13 16:13:21 -05:00
Greg Wilkins 9706d70484
Jetty 9.4.x reformat (#3811)
* Removing Legacy Method Separators
* Restyling branch `jetty-9.4.x`
* Applying changes highlighted by checkstyle
* Applying XML restyling
* Fixing XML codestyle for IntelliJ
* Fixing XML style mistakes
* Revert "Applying XML restyling"
* Updating checkstyle for XML codestyle
* Reformatting pom.xml files
* Fixed empty string from line wraps
* Update intellij style to not do expression relative formatting. Reformatted code based on that.
* Increasing line split on Eclipse IDE Formatter to 512
* Restoring setting on internal default value.
+ IntelliJ will not export settings on things that set to their
  internal default values.
  We want to keep those values as a hedge against future default
  value changes in future releases of IntelliJ.
* Fixing intellij codestyle
* do not allow single line simple methods
* misc checkstyle fixes
* re-exported with correct name and all values

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
2019-06-24 17:40:30 +02:00
Joakim Erdfelt 40e9e053b9
Merge pull request #3768 from eclipse/jetty-9.4.x-3708-stringutil-replace
Issue #3708 - use StringUtil alternatives for known slow JVM impls.
2019-06-13 14:01:35 -05:00
Joakim Erdfelt 877815e195 Issue #3708 - Adding new methods and converting codebase to use them
+ StringUtil.replace(String, char, char)
+ StringUtil.strip(String, String)
+ URIUtil.encodeSpecific(String, String)
+ URIUtil.decodeSpecific(String, String)
+ TypeUtil.toClassReference(Class)
+ TypeUtil.toClassReference(String)

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2019-06-12 09:56:41 -05:00
Joakim Erdfelt 33fe55c339 Issue #3708 - use StringUtil alternatives for known slow JVM impls.
+ StringUtil.replace()
+ StringUtil.replaceFirst()
+ StringUtil.sanitizeFileSystemPath()

Change existing usages of String.replace() to either
use new StringUtil.replace() or other methods elsewhere
that better suit that specific need.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2019-06-11 11:25:50 -05:00
Joakim Erdfelt ae21126cad Updating to version 9.4.20-SNAPSHOT 2019-06-10 13:40:17 -05:00
Joakim Erdfelt afcf563148 Updating to version 9.4.19.v20190610 2019-06-10 11:17:56 -05:00
Joakim Erdfelt b44ecc932a Issue #2909 - Replace B64Code with java.util.Base64
+ Deprecated B64Code
+ All code that isn't B64CodeTest is now using java.util.Base64
+ B64CodeTest is updated to confirm change to java.util.Base64
  is possible without change in behavior. Just have to make
  sure you use the appropriate Encoder / Decoder for the task
  at hand (default vs mime vs url)

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2019-05-15 10:08:11 +02:00
Gary Gregory 8155942344 Allow subclasses to map exceptions to status codes.
Signed-off-by: Gary Gregory <garydgregory@gmail.com>
2019-05-07 09:59:09 -04:00
Joakim Erdfelt e33dfabba9 Moving to IPv6 Assumption (from junit Group/Tag)
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2019-04-30 12:26:14 -05:00
Joakim Erdfelt 734be56938 Updating to version 9.4.19-SNAPSHOT 2019-04-29 16:27:23 -05:00
Joakim Erdfelt e1bc35120a Updating to version 9.4.18.v20190429 2019-04-29 15:40:33 -05:00
Joakim Erdfelt 05bb111580 Updating to version 9.4.18-SNAPSHOT 2019-04-18 15:59:49 -05:00
Joakim Erdfelt aa1c656c31 Updating to version 9.4.17.v20190418 2019-04-18 14:44:28 -05:00
Joakim Erdfelt 79537a5f51 Updating to version 9.4.17-SNAPSHOT 2019-04-11 11:00:24 -05:00
Joakim Erdfelt e0aa4ae4c0 Updating to version 9.4.16.v20190411 2019-04-11 10:01:26 -05:00
olivier lamy 4ad8553fb1 fix format removing extra space
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
2019-04-07 10:06:06 +10:00
Olivier Lamy 8829602201
Exclude ipv6 tests for ci profile (Jenkins) (#3528)
* exclude ipv6 test as currently failing on kubernetes, using junit tag and ci profile activated via Jenkinsfile

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>

* upgrade surefire to 3.0.0-M3

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
2019-04-06 13:27:42 +10:00
Simone Bordet 6fb243ff6c Issue #3464 - Split SslContextFactory into Client and Server
Introduced SslContextFactory subclasses Client and Server.
Replaced all usages of SslContextFactory with either Client or Server
as required.

Refactored configuration checking so that warnings are not emitted
when non necessary.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2019-03-21 14:42:42 +01:00
Greg Wilkins 76a37352f5 Issue #3440 Stop on Unavailable
+ revert schedulers to non-daemon threads for now so this PR can
   proceed.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
2019-03-12 09:21:19 +11:00
Greg Wilkins 375ad81f4b Issue #3440 Stop on Unavailable
+ Any schedulers created are named (for ease of debug) and daemon
   so they do not stop the JVM exiting.
 + If the server.doStart() fails, it calls server.doStop to ensure
   connectors are stopped, ports are free etc.
 + cleanup of addBean handling of scheduler in proxy

Signed-off-by: Greg Wilkins <gregw@webtide.com>
2019-03-07 15:10:53 +11:00
Simone Bordet 057575f1cb Issue #3373 - OutOfMemoryError: Java heap space in GZIPContentDecoder.
Modified jetty-client content decoding to be fully non-blocking;
this allows for a better backpressure and less usage of the buffer
pool.

Modified GZIPContentDecoder to aggregate decoded ByteBuffers in
a smarter way that avoids too many data copies and pollution of
the buffer pool with intermediate size buffers.

Removed duplicate test GZIPContentDecoderTest.

Improved javadocs and improved AsyncMiddleManServlet
to release buffers used by the GZIPContentDecoder.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2019-02-28 16:11:26 +01:00
Joakim Erdfelt 9cdb59d4d7 Updating to version 9.4.16-SNAPSHOT 2019-02-15 13:35:15 -05:00
Joakim Erdfelt eb70b24016 Updating to version 9.4.15.v20190215 2019-02-15 11:53:00 -05:00
Simone Bordet 88408375ab Issue #3049 - Warn on common SslContextFactory problematic configurations.
Updating SslContextFactory configuration for tests, since
the change in the default endPointIdentificationAlgorithm
makes the test failing as the certificates are not valid
for the local host, which is different depending on where
the tests are run (locally, jenkins).

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2019-01-31 15:31:35 +01:00
Greg Wilkins ce3defa2f5 fixed debug
Signed-off-by: Greg Wilkins <gregw@webtide.com>
2019-01-10 09:07:02 +11:00
Olivier Lamy 9b7afd8a03
Happy new year!! (#3232)
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
2019-01-01 11:52:16 +10:00
Joakim Erdfelt 29fd18e046 Updating to version 9.4.15-SNAPSHOT 2018-11-14 16:42:40 -06:00
Joakim Erdfelt c4550056e7 Updating to version 9.4.14.v20181114 2018-11-14 15:19:10 -06:00
Joakim Erdfelt a903017f5f Updating to version 9.4.14-SNAPSHOT 2018-11-11 21:06:50 -06:00
Joakim Erdfelt 49123a3313 Updating to version 9.4.13.v20181111 2018-11-11 20:02:42 -06:00
Greg Wilkins 15e1c73f9c
Cleanup the dump implementation (#2998)
* Cleanup the dump implementation
* improved the clarity of utility methods for dump and updated most dump methods
* fixed upgrade filter dump
* Improved dump after review
* Moved dumpObjects to Dumpable
* implemented dumpBeans with dumpObjects
* less verbose dump
* Dump streams
* fixed dump test

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2018-10-22 11:53:59 +11:00
Simone Bordet 85d512ceec Restored proper test timeout.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2018-10-02 21:55:09 +02:00
Joakim Erdfelt a3f1592c50 Issue #2431 - Upgrade to Junit 5 (#2436)
+ Changes needed for new Junit 5
+ Migrating from Vintage junit API to Jupiter junit API
+ Relies on SNAPSHOT jetty-test-helper
  - this will be a formal release once this issue has been
    resolved satisfactory
+ Have jenkins always pull latest SNAPSHOT for each build
+ Adding jetty.snapshots repository
+ Using surefire 2.22.0 per advice from junit
+ Ensuring <reuseForks>true</reuseForks> to work around issue junit-team/junit5#801
+ Disabling <forkMode>always</forkMode> in maven-surefire-plugin
  due to bug https://github.com/junit-team/junit5/issues/801
+ OSGi tests must remain at vintage due to PaxExam
+ Moving from vintage TestingDir to jupiter WorkDir
+ Fixing imports to use jupiter, not vintage
+ Migrating vintage ExpectedException to jupiter assertThrows
+ Migrating vintage TestName to jupiter TestInfo
+ Migrating @RunWith(Parameterized.class)
  to @ParameterizedTest with Argument Sources
+ Migrating assertTrue(val.contains(needle))
  to assertThat(val, containsString(needle))
+ Aligning junit versions per recommendations from @sormuras
+ Adjusting parameter order change for assertEquals()
+ Test LifeCycle Annotation Migration

junit 4      | junit 5 / jupiter
------------ | -----------
@Before      | @BeforeEach
@After       | @AfterEach
@BeforeClass | @BeforeAll
@AfterClass  | @AfterAll

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
2018-09-05 10:07:17 +10:00
Jesse McConnell dcf6a8fa9f
Updating to version 9.4.13-SNAPSHOT 2018-08-30 10:48:22 -05:00
Jesse McConnell 2720868475
Updating to version 9.4.12.v20180830 2018-08-30 08:56:44 -05:00
Joakim Erdfelt 0b69f00665 Updating to version 9.4.12-SNAPSHOT 2018-07-11 17:32:16 -05:00
Joakim Erdfelt 260596dd10 Updating to version 9.4.12.RC0 2018-07-11 16:30:55 -05:00
Greg Wilkins 346879f2a5
Merge pull request #2664 from mperktold/jetty-9.4.x
Issue #2662 Unnecessary boxing conversions
2018-06-13 22:52:27 +02:00
Matthias Perktold f901efc413 Issue #2662 - Unnecessary boxing conversions
Signed-off-by: Matthias Perktold <tias251@gmail.com>
2018-06-13 16:20:12 +02:00
Joakim Erdfelt e4bfe00dce Updating to version 9.4.12-SNAPSHOT 2018-06-05 14:18:37 -05:00
Joakim Erdfelt d5fc0523cf Updating to version 9.4.11.v20180605 2018-06-05 13:23:02 -05:00
Joakim Erdfelt 1732ffca51 Updating to version 9.4.11-SNAPSHOT 2018-05-03 11:48:05 -05:00
Joakim Erdfelt daa59876e6 Updating to version 9.4.10.v20180503 2018-05-03 10:55:19 -05:00
Assim Deodia eeeffed73a AsyncMiddleManServlet.Transparent class wrongly extends ProxyServlet
`AsyncMiddleManServlet.Transparent` class should extend `AsyncMiddleManServlet`
so the consumers can override the `newServerResponseContentTransformer` &
`newServerResponseContentTransformer` to provide their own ContentTransformer.

The way it is structured right now makes it impossible to use
`AsyncMiddleManServlet.Transparent` servlet as a middle man servlet.

Signed-off-by: Assim Deodia <assim.deodia@gmail.com>
2018-04-24 18:12:00 -07:00
Olivier Lamy f36eba4577
class.newInstance is deprecated #2435 (#2437)
* Class.newInstance() is deprecated in Java 9+ #2435

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
2018-04-17 19:07:20 +10:00
Joakim Erdfelt c3cc138a3b Updating to version 9.4.10-SNAPSHOT 2018-03-20 08:25:59 -05:00