Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove pre-jdk1.4 workarounds #123

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions archived/jtopenlite/com/ibm/jtopenlite/EncryptPassword.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ static byte[] encryptPasswordSHA(byte[] userID, byte[] password, byte[] clientSe
}
catch (NoSuchAlgorithmException e)
{
IOException io = new IOException("Error loading SHA encryption: "+e);
io.initCause(e);
throw io;
throw new IOException("Error loading SHA encryption: " + e, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ public byte[] getBytes(long pos, int length) throws SQLException
}
catch (IOException io)
{
SQLException sql = new SQLException(io.toString());
sql.initCause(io);
throw sql;
throw new SQLException(io);
}
}

Expand Down Expand Up @@ -121,9 +119,7 @@ public long length() throws SQLException
}
catch (IOException io)
{
SQLException sql = new SQLException(io.toString());
sql.initCause(io);
throw sql;
throw new SQLException(io);
}
}
return length_;
Expand Down
20 changes: 5 additions & 15 deletions archived/jtopenlite/com/ibm/jtopenlite/database/jdbc/JDBCClob.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ public InputStream getAsciiStream() throws SQLException
}
catch (UnsupportedEncodingException uee)
{
SQLException sql = new SQLException(uee.toString());
sql.initCause(uee);
throw sql;
throw new SQLException(uee);
}
}

Expand All @@ -98,9 +96,7 @@ public Reader getCharacterStream() throws SQLException
}
catch (UnsupportedEncodingException uee)
{
SQLException sql = new SQLException(uee.toString());
sql.initCause(uee);
throw sql;
throw new SQLException(uee);
}
}

Expand All @@ -119,9 +115,7 @@ public String getSubString(long pos, int length) throws SQLException
}
catch (UnsupportedEncodingException uee)
{
SQLException sql = new SQLException(uee.toString());
sql.initCause(uee);
throw sql;
throw new SQLException(uee);
}
}

Expand Down Expand Up @@ -159,9 +153,7 @@ public long position(String patternString, long start) throws SQLException
}
catch (UnsupportedEncodingException uee)
{
SQLException sql = new SQLException(uee.toString());
sql.initCause(uee);
throw sql;
throw new SQLException(uee);
}
}

Expand Down Expand Up @@ -199,9 +191,7 @@ public int setString(long pos, String str, int offset, int len) throws SQLExcept
}
catch (UnsupportedEncodingException uee)
{
SQLException sql = new SQLException(uee.toString());
sql.initCause(uee);
throw sql;
throw new SQLException(uee);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ public class JDBCDriver implements Driver
}
catch (SQLException sql)
{
RuntimeException re = new RuntimeException("Error registering driver: "+sql.toString());
re.initCause(sql);
throw re;
throw new RuntimeException("Error registering driver: "+sql.toString(), sql);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,7 @@ public InputStream getUnicodeStream(int i) throws SQLException
}
catch (UnsupportedEncodingException uee)
{
SQLException sql = new SQLException(uee.toString());
sql.initCause(uee);
throw sql;
throw new SQLException(uee);
}
}

Expand All @@ -1031,9 +1029,7 @@ public InputStream getUnicodeStream(String colName) throws SQLException
}
catch (UnsupportedEncodingException uee)
{
SQLException sql = new SQLException(uee.toString());
sql.initCause(uee);
throw sql;
throw new SQLException(uee);
}
}

Expand All @@ -1047,9 +1043,7 @@ public URL getURL(int i) throws SQLException
}
catch (MalformedURLException e)
{
SQLException sql = new SQLException("Data conversion error");
sql.initCause(e);
throw sql;
throw new SQLException("Data conversion error", e);
}
}

Expand Down
15 changes: 2 additions & 13 deletions src/main/java/com/ibm/as400/access/AS400.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@
public class AS400 implements Serializable, AutoCloseable
{
private static final String CLASSNAME = "com.ibm.as400.access.AS400";
static boolean jdk14 = false;

static
{
if (Trace.traceOn_) Trace.logLoadPath(CLASSNAME);
jdk14 = JVMInfo.isJDK14();
}

static final long serialVersionUID = 4L;
Expand Down Expand Up @@ -1928,17 +1926,8 @@ private int getDaysToExpiration() {
GregorianCalendar expirationDate = signonInfo_.expirationDate;
GregorianCalendar now = signonInfo_.currentSignonDate;
if (expirationDate != null && now != null) {
// getTimeInMillis() is protected in JDK 1.3 and cannot be used
long lExpiration;
long lNow;
if (jdk14) {
lExpiration = expirationDate.getTimeInMillis();
lNow = now.getTimeInMillis();
} else {
lExpiration = expirationDate.getTime().getTime();
lNow = now.getTime().getTime();

}
long lExpiration = expirationDate.getTimeInMillis();
long lNow = now.getTimeInMillis();

// Divide by number of seconds in day, round up.
int days = (int) (((lExpiration - lNow) / 0x5265C00) + 1);
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/com/ibm/as400/access/AS400FTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,7 @@ public synchronized boolean connect()
if (Trace.isTraceOn())
Trace.log(Trace.DIAGNOSTIC,"Security exception in getVRM()", e);

IOException throwException = new IOException(e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {}
throw throwException;
throw new IOException(e);
}

AS400ImplRemote systemImpl = (AS400ImplRemote)system_.getImpl(); // @D2a
Expand Down Expand Up @@ -942,11 +938,7 @@ private void saveFileProcessing(String target)
{
if (Trace.isTraceOn())
Trace.log(Trace.DIAGNOSTIC,"IO Exception running command call ", e);
IOException throwException = new IOException(e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {}
throw throwException;
throw new IOException(e);

}

Expand Down
15 changes: 3 additions & 12 deletions src/main/java/com/ibm/as400/access/AS400ImplRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,7 @@ public int createUserHandle() throws AS400SecurityException, IOException {
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(
e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {
}
throwException.initCause(e);
throw throwException;
}
// Verify that we got a handle back.
Expand Down Expand Up @@ -691,10 +688,7 @@ public int createUserHandle() throws AS400SecurityException, IOException {
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(
e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {
}
throwException.initCause(e);
throw throwException;
}

Expand Down Expand Up @@ -4691,10 +4685,7 @@ public int createUserHandle2() throws AS400SecurityException, IOException {
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(
e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {
}
throwException.initCause(e);
throw throwException;
} catch (Throwable e) {
Trace.log(Trace.ERROR, "Error retrieving GSSToken:", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,7 @@ public class AS400JDBCDataSourceBeanInfo extends SimpleBeanInfo
}
catch(Exception e)
{
Error error = new Error(e.toString());
error.initCause(e);
throw error ;
throw new Error(e) ;
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/ibm/as400/access/AS400JDBCInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,7 @@ public synchronized int read(byte[] data, int start, int length) throws IOExcept
//@pdd e.printStackTrace(DriverManager.getLogStream());
closed_ = true;
}
IOException throwException = new IOException(e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {}
throw throwException;
throw new IOException(e);
}
}

Expand Down
12 changes: 2 additions & 10 deletions src/main/java/com/ibm/as400/access/AS400JDBCOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ public synchronized void write(byte[] byteArray, int off, int len) throws IOExce
JDTrace.logException(this, "Exception caught", e);
}
closed_ = true;
IOException throwException = new IOException(e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {}
throw throwException;
throw new IOException(e);

}
}
Expand Down Expand Up @@ -144,11 +140,7 @@ public synchronized void write(int b) throws IOException
JDTrace.logException(this, "Exception caught", e);
}
closed_ = true;
IOException throwException = new IOException(e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {}
throw throwException;
throw new IOException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1753,12 +1753,7 @@ public int[] executeBatch() throws SQLException {
}
BatchUpdateException batchUpdateException = new BatchUpdateException(
e.getMessage(), e.getSQLState(), e.getErrorCode(), counts);
// Attempt to set the cause, ignoring any failures (i.e. in Pre JDK 1.4)
// /*@DAA*/
try {
batchUpdateException.initCause(e);
} catch (java.lang.NoSuchMethodError e2) {
}
batchUpdateException.initCause(e);

throw batchUpdateException;
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ibm/as400/access/AS400JDBCResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -6075,7 +6075,7 @@ else if(cursor.getCursorAttributeHoldable() == 1

//if above cannot determine holdability, then do best guess
if(connection_ instanceof AS400JDBCConnection && connection_ != null) //@cur
return ((AS400JDBCConnection) connection_).getHoldability(); //@cur CAST needed for JDK 1.3
return connection_.getHoldability(); //@cur
else //@cur
return ResultSet.CLOSE_CURSORS_AT_COMMIT; //@cur (if no statment exists for this, then safest is to return close at commit to prevent cursor reuse errors)
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/ibm/as400/access/AS400JDBCStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -2511,9 +2511,7 @@ public int[] executeBatch ()
batch_.removeAllElements ();
BatchUpdateException throwException = new BatchUpdateException (e.getMessage (),
e.getSQLState (), e.getErrorCode (), updateCounts2);
try {
throwException.initCause(e);
} catch (Throwable t) {}
throwException.initCause(e);
throw throwException;
}

Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/ibm/as400/access/AS400JDBCWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ public synchronized void write(String str, int off, int len) throws IOException
JDTrace.logException(this, "Exception caught", e);
}
closed_ = true;
IOException throwException = new IOException(e.getMessage());
try {
throwException.initCause(e);
} catch (Throwable t) {}
throw throwException;
throw new IOException(e);
}
}
}
6 changes: 2 additions & 4 deletions src/main/java/com/ibm/as400/access/AS400JDBCXAResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,8 @@ private void throwXAException(Exception e)
{
JDTrace.logException(this, "throwing XAException(XAER_RMFAIL) because of", e);
}
XAException xaex = new XAException(XAException.XAER_RMFAIL);
try {
xaex.initCause(e);
} catch (Throwable t) {}
XAException xaex = new XAException(XAException.XAER_RMFAIL);
xaex.initCause(e);
throw xaex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,8 @@ protected AS400SecurityException(int returnCode)
/*@M4A*/
protected AS400SecurityException(int returnCode, Throwable e)
{
super(ResourceBundleLoader.getText(getMRIKey(returnCode)));
super(ResourceBundleLoader.getText(getMRIKey(returnCode)), e);
rc_ = returnCode;
// Remember the cause of the exception
try {
initCause(e);
} catch (Throwable t) { }
}

// Constructs an AS400SecurityException object.
Expand Down
20 changes: 4 additions & 16 deletions src/main/java/com/ibm/as400/access/ClassDecoupler.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ static Object[] connectDDMPhase1(OutputStream outStream, InputStream inStream, b
keyPair = DDMTerm.getAESKeyPair();
}
} catch (GeneralSecurityException e) {
ServerStartupException serverStartupException = new ServerStartupException(
ServerStartupException.CONNECTION_NOT_ESTABLISHED);
serverStartupException.initCause(e);
throw serverStartupException;
throw new ServerStartupException(ServerStartupException.CONNECTION_NOT_ESTABLISHED, e);
}
} else {
requestByteType = byteType_;
Expand Down Expand Up @@ -145,10 +142,7 @@ static Object[] connectDDMPhase1(OutputStream outStream, InputStream inStream, b
keyPair = DDMTerm.getAESKeyPair();
}
} catch (GeneralSecurityException e) {
ServerStartupException serverStartupException = new ServerStartupException(
ServerStartupException.CONNECTION_NOT_ESTABLISHED);
serverStartupException.initCause(e);
throw serverStartupException;
throw new ServerStartupException(ServerStartupException.CONNECTION_NOT_ESTABLISHED, e);
}

ACCSECReq = new DDMACCSECRequestDataStream(aesEncryption, requestByteType, null, keyPair, forceAES); // We currently don't need to pass the IASP to the ACCSEC, but may in the future.
Expand All @@ -167,10 +161,7 @@ static Object[] connectDDMPhase1(OutputStream outStream, InputStream inStream, b
keyPair = DDMTerm.getAESKeyPair();
forceAES = true;
} catch (GeneralSecurityException e) {
ServerStartupException serverStartupException = new ServerStartupException(
ServerStartupException.CONNECTION_NOT_ESTABLISHED);
serverStartupException.initCause(e);
throw serverStartupException;
throw new ServerStartupException(ServerStartupException.CONNECTION_NOT_ESTABLISHED, e);
}

ACCSECReq = new DDMACCSECRequestDataStream(aesEncryption, requestByteType, null, keyPair, forceAES); // We currently don't need to pass the IASP to the ACCSEC, but may in the future.
Expand Down Expand Up @@ -201,10 +192,7 @@ static Object[] connectDDMPhase1(OutputStream outStream, InputStream inStream, b
keyPair = DDMTerm.getAESKeyPair();
forceAES = true;
} catch (GeneralSecurityException e) {
ServerStartupException serverStartupException = new ServerStartupException(
ServerStartupException.CONNECTION_NOT_ESTABLISHED);
serverStartupException.initCause(e);
throw serverStartupException;
throw new ServerStartupException(ServerStartupException.CONNECTION_NOT_ESTABLISHED, e);
}

ACCSECReq = new DDMACCSECRequestDataStream(aesEncryption, requestByteType, null, keyPair, forceAES); // We currently don't need to pass the IASP to the ACCSEC, but may in the future.
Expand Down
Loading