-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing behavior of logback-access in the modern era
+ Fixes LOGBACK-1580 to report the proper HttpServletResponse.getStatus() that was used when the response was committed. + Works around LOGBACK-1581 in AccessEvent to not fail logging when the HttpServletRequest.getParameterNames() or HttpServletRequest.getParameter(String) methods are used against unread or even bad request objects. + Updated Javadoc (needs to be copied over to logback manual though) + Must use OpenJDK 1.8 to compile and release. + Still compiles to Java 1.6 bytecode for release.
- Loading branch information
Showing
5 changed files
with
298 additions
and
90 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
logback-access/src/main/java/ch/qos/logback/access/jetty/JettyModernServerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Logback: the reliable, generic, fast and flexible logging framework. | ||
* Copyright (C) 1999-2015, QOS.ch. All rights reserved. | ||
* | ||
* This program and the accompanying materials are dual-licensed under | ||
* either the terms of the Eclipse Public License v1.0 as published by | ||
* the Eclipse Foundation | ||
* | ||
* or (per the licensee's choosing) | ||
* | ||
* under the terms of the GNU Lesser General Public License version 2.1 | ||
* as published by the Free Software Foundation. | ||
*/ | ||
package ch.qos.logback.access.jetty; | ||
|
||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import ch.qos.logback.access.spi.ServerAdapter; | ||
import org.eclipse.jetty.http.HttpField; | ||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.server.Response; | ||
|
||
/** | ||
* A Jetty 9.4.x and 10.0.x specific implementation of the {@link ServerAdapter} interface. | ||
* | ||
* @author Sébastien Pennec | ||
* @author Ceki Gulcu | ||
* @author Joakim Erdfelt | ||
*/ | ||
public class JettyModernServerAdapter extends JettyServerAdapter | ||
{ | ||
public JettyModernServerAdapter(Request jettyRequest, Response jettyResponse) { | ||
super(jettyRequest, jettyResponse); | ||
} | ||
|
||
@Override | ||
public long getContentLength() { | ||
return response.getHttpChannel().getBytesWritten(); | ||
} | ||
|
||
@Override | ||
public int getStatusCode() { | ||
return response.getCommittedMetaData().getStatus(); | ||
} | ||
|
||
@Override | ||
public long getRequestTimestamp() { | ||
return request.getTimeStamp(); | ||
} | ||
|
||
@Override | ||
public Map<String, String> buildResponseHeaderMap() { | ||
Map<String, String> responseHeaderMap = new HashMap<String, String>(); | ||
Iterator<HttpField> httpFieldIter = response.getHttpFields().iterator(); | ||
while (httpFieldIter.hasNext()) { | ||
HttpField httpField = httpFieldIter.next(); | ||
String key = httpField.getName(); | ||
String value = httpField.getValue(); | ||
responseHeaderMap.put(key, value); | ||
} | ||
return responseHeaderMap; | ||
} | ||
|
||
} |
Oops, something went wrong.