Skip to content

Commit

Permalink
Merge pull request #3871 from kalaiyarasiganeshalingam/master
Browse files Browse the repository at this point in the history
Handle resources properly
  • Loading branch information
arunans23 authored Jan 20, 2025
2 parents e7d921d + 445f10d commit ec4928e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ public HttpSession getSession(boolean b) {

@Override
public HttpSession getSession() {
HttpSession oldSession = getSession(false);
if (oldSession != null) {
oldSession.invalidate();
}
return req.getSession();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.math.BigDecimal;
Expand Down Expand Up @@ -831,8 +832,11 @@ private void bindValuesToPreparedStatement(int type, String value, int ordinalPo
if (value == null) {
sqlStatement.setNull(ordinalPosition, type);
} else {
sqlStatement.setClob(ordinalPosition, new BufferedReader(new StringReader(value)),
value.length());
try (BufferedReader reader = new BufferedReader(new StringReader(value))) {
sqlStatement.setClob(ordinalPosition, reader, value.length());
} catch (IOException e) {
sqlStatement.setNull(ordinalPosition, type);
}
}
break;
case Types.BOOLEAN:
Expand Down Expand Up @@ -911,8 +915,11 @@ private void bindValuesToPreparedStatement(int type, String value, int ordinalPo
if (value == null) {
sqlStatement.setNull(ordinalPosition, type);
} else {
sqlStatement.setNClob(ordinalPosition, new BufferedReader(new StringReader(value)),
value.length());
try (BufferedReader reader = new BufferedReader(new StringReader(value))) {
sqlStatement.setNClob(ordinalPosition, reader, value.length());
} catch (IOException e) {
sqlStatement.setNull(ordinalPosition, type);
}
}
break;
case Types.BIGINT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

public class SSLHandlerFactory {

private static final String protocol = "TLS";
private static final String protocol = "TLSv1.2";
private final SSLContext serverContext;
private boolean needClientAuth;
private String[] cipherSuites;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,9 @@ private byte[] symmetricDecryptData(HybridEncryptionOutput hybridEncryptionOutpu
}
if ((hybridEncryptionOutput.getAuthData() != null) && (hybridEncryptionOutput.getAuthTag() != null)) {
cipher.updateAAD(hybridEncryptionOutput.getAuthData());
return cipher.doFinal(concatByteArrays(
new byte[][] { hybridEncryptionOutput.getCipherData(), hybridEncryptionOutput.getAuthTag() }));
byte[] encryptedDataWithTag = concatByteArrays(
new byte[][] { hybridEncryptionOutput.getCipherData(), hybridEncryptionOutput.getAuthTag() });
return cipher.doFinal(encryptedDataWithTag);
} else {
return cipher.doFinal(hybridEncryptionOutput.getCipherData());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ public String getServletPath() {
}

public HttpSession getSession() {
HttpSession oldSession = getSession(false);
if (oldSession != null) {
oldSession.invalidate();
}
return wrappedHttpServletRequest.getSession();
}

Expand Down

0 comments on commit ec4928e

Please sign in to comment.