Skip to content

Commit d7fb4cc

Browse files
author
oleksiys
committed
[1.8.x] + close the transaction, if connection is closed locally
1 parent 25002d5 commit d7fb4cc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/main/java/com/ning/http/client/providers/grizzly/FeedableBodyGenerator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2014 Sonatype, Inc. All rights reserved.
2+
* Copyright (c) 2012-2015 Sonatype, Inc. All rights reserved.
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
@@ -38,6 +38,7 @@
3838
import static java.lang.Boolean.TRUE;
3939
import static java.util.concurrent.TimeUnit.MILLISECONDS;
4040
import static org.glassfish.grizzly.ssl.SSLUtils.getSSLEngine;
41+
import org.glassfish.grizzly.utils.Exceptions;
4142
import static org.glassfish.grizzly.utils.Exceptions.*;
4243

4344
/**
@@ -215,6 +216,10 @@ private void flushOnSSLHandshakeComplete() throws IOException {
215216
public void onStart(Connection connection) {
216217
}
217218

219+
public void onFailure(Connection connection, Throwable t) {
220+
connection.closeWithReason(Exceptions.makeIOException(t));
221+
}
222+
218223
public void onComplete(Connection connection) {
219224
if (c.equals(connection)) {
220225
filter.removeHandshakeListener(this);
@@ -225,10 +230,6 @@ public void onComplete(Connection connection) {
225230
}
226231
}
227232
}
228-
229-
public void onFailure(Connection connection, Throwable t) {
230-
231-
}
232233
});
233234
filter.handshake(context.getConnection(), null);
234235
}

src/main/java/com/ning/http/client/providers/grizzly/GrizzlyAsyncHttpProvider.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2014 Sonatype, Inc. All rights reserved.
2+
* Copyright (c) 2012-2015 Sonatype, Inc. All rights reserved.
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
@@ -658,6 +658,12 @@ public void onClosed(Closeable closeable, CloseType type) throws IOException {
658658
new GracefulCloseEvent(HttpTransactionContext.this), null);
659659
} else if (CloseType.REMOTELY.equals(type)) {
660660
abort(REMOTELY_CLOSED_EXCEPTION);
661+
} else {
662+
try {
663+
closeable.assertOpen();
664+
} catch (IOException ioe) {
665+
abort(ioe);
666+
}
661667
}
662668
}
663669
};

0 commit comments

Comments
 (0)