Skip to content

Commit 05773e2

Browse files
committed
Minor fixes.
1 parent a9479a1 commit 05773e2

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

modules/org.restlet/src/org/restlet/engine/adapter/Call.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,21 @@ public abstract class Call {
5252
public static boolean isBroken(Throwable exception) {
5353
boolean result = false;
5454

55-
if (exception.getMessage() != null) {
56-
result = (exception.getMessage().indexOf("Broken pipe") != -1)
57-
|| (exception
58-
.getMessage()
59-
.equals("An existing connection must have been closed by the remote party.") || (exception
60-
.getMessage()
61-
.equals("An open connection has been abandonned by your network stack.")));
55+
// detect Tomcat and Jetty exceptions
56+
if (exception instanceof IOException) {
57+
String exceptionName = exception.getClass().getName();
58+
result = (exceptionName.endsWith("ClientAbortException") ||
59+
exceptionName.endsWith("jetty.io.EofException"));
60+
}
61+
62+
// check for known exception messages
63+
if (!result) {
64+
String exceptionMessage = exception.getMessage();
65+
if (exceptionMessage != null) {
66+
result = (exceptionMessage.indexOf("Broken pipe") != -1) ||
67+
(exceptionMessage.equals("An existing connection must have been closed by the remote party.") ||
68+
(exceptionMessage.equals("An open connection has been abandonned by your network stack.")));
69+
}
6270
}
6371

6472
if (!result && exception.getCause() != null) {

modules/org.restlet/src/org/restlet/engine/adapter/ServerAdapter.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected void addResponseHeaders(HttpResponse response) {
104104
/**
105105
* Commits the changes to a handled uniform call back into the original HTTP
106106
* call. The default implementation first invokes the "addResponseHeaders"
107-
* then asks the "httpCall" to send the response back to the client.
107+
* then asks the "htppCall" to send the response back to the client.
108108
*
109109
* @param response
110110
* The high-level response.
@@ -188,10 +188,8 @@ public void commit(HttpResponse response) {
188188
} catch (Throwable t) {
189189
// [ifndef gae]
190190
if (response.getHttpCall().isConnectionBroken(t)) {
191-
getLogger()
192-
.log(Level.INFO,
193-
"The connection was broken. It was probably closed by the client.",
194-
t);
191+
// output a single log line for this common case to avoid filling servers logs
192+
getLogger().log(Level.INFO, "The connection was broken. It was probably closed by the client. Reason: " + t.getMessage());
195193
} else
196194
// [enddef]
197195
{

modules/org.restlet/src/org/restlet/engine/resource/MethodAnnotationInfo.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.restlet.data.Metadata;
3939
import org.restlet.data.Method;
4040
import org.restlet.data.Parameter;
41+
import org.restlet.engine.util.StringUtils;
4142
import org.restlet.representation.Representation;
4243
import org.restlet.representation.Variant;
4344
import org.restlet.service.MetadataService;
@@ -80,7 +81,7 @@ public MethodAnnotationInfo(Class<?> javaClass, Method restletMethod,
8081
this.restletMethod = restletMethod;
8182

8283
// Parse the main components of the annotation value
83-
if ((annotationValue != null) && !annotationValue.equals("")) {
84+
if (!StringUtils.isNullOrEmpty(annotationValue)) {
8485
int queryIndex = annotationValue.indexOf('?');
8586

8687
if (queryIndex != -1) {
@@ -288,6 +289,7 @@ private List<Variant> getVariants(MetadataService metadataService,
288289
List<Variant> result = null;
289290

290291
if (annotationValue != null) {
292+
291293
StringTokenizer stValue = new StringTokenizer(annotationValue,
292294
"\\|");
293295
while (stValue.hasMoreTokens()) {
@@ -305,6 +307,7 @@ private List<Variant> getVariants(MetadataService metadataService,
305307
if (extension == null) {
306308
continue;
307309
}
310+
308311
List<Metadata> metadataList = metadataService
309312
.getAllMetadata(extension);
310313

0 commit comments

Comments
 (0)