Skip to content

Commit

Permalink
Version 3.6.2 fixing issues
Browse files Browse the repository at this point in the history
- Fix issue on Databases (Limit, H2 sequence)
- Fix SystemProperty bad handling
- Fix Web Testing issue
- Fix no database issue
- Fix Elasticsearch client issue
- Fix #108 issue on FTP to allow OPTS command before login
- Fix #110 issue to allow to configure CIPHER and Protocols used by TLS
- Upgrade dependencies

Note that strange behavior with JDK 11 implies to use JDK 13 to build jre11 version.
  • Loading branch information
fredericBregier committed Jul 11, 2022
1 parent ea7ce24 commit 3244684
Show file tree
Hide file tree
Showing 104 changed files with 2,048 additions and 1,894 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
*.jpg binary
*.jar binary
lib/phantomjs* binary
lib/geckodriver* binary

22 changes: 22 additions & 0 deletions WaarpCommon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,28 @@
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.detro</groupId>
<artifactId>ghostdriver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
</project>
29 changes: 29 additions & 0 deletions WaarpCommon/src/main/java/org/waarp/common/command/ReplyCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public enum ReplyCode {
*/
REPLY_350_REQUESTED_FILE_ACTION_PENDING_FURTHER_INFORMATION(350),

/**
* 400 Bad Request (Http)
*/
REPLY_400_BAD_REQUEST(400),

/**
* 421 Service not available, closing control connection. This may be a
* reply
Expand Down Expand Up @@ -457,6 +462,8 @@ public static ReplyCode getReplyCode(final int code)
return REPLY_332_NEED_ACCOUNT_FOR_LOGIN;
case 350:
return REPLY_350_REQUESTED_FILE_ACTION_PENDING_FURTHER_INFORMATION;
case 400:
return REPLY_400_BAD_REQUEST;
case 421:
return REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION;
case 425:
Expand Down Expand Up @@ -507,4 +514,26 @@ public static ReplyCode getReplyCode(final int code)
throw new InvalidArgumentException("Unknown ReplyCode " + code);
}
}

/**
* @param httpCode
*
* @return the associated ReplyCode from the given numerical code
*
* @throws InvalidArgumentException
*/
public static ReplyCode getReplyCodeFromHttp(final int httpCode)
throws InvalidArgumentException {
if (httpCode < 200) {
return REPLY_000_SPECIAL_NOSTATUS;
} else if (httpCode < 300) {
return REPLY_200_COMMAND_OKAY;
} else if (httpCode < 400) {
return REPLY_220_SERVICE_READY;
} else if (httpCode < 500) {
return REPLY_400_BAD_REQUEST;
} else {
return REPLY_500_SYNTAX_ERROR_COMMAND_UNRECOGNIZED;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public static int getNbConnection() {
* Close all database connections
*/
public static void closeAllConnection() {
logger.error("DEBUG Close All Connections");
logger.debug("DEBUG Close All Connections");
for (final DbSession session : listConnection.values()) {
logger.debug("Close (all) Db Conn: {}", session.getInternalId());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@
*/
package org.waarp.common.database;

import org.waarp.common.database.model.DbType;
import org.waarp.common.logging.WaarpLogger;
import org.waarp.common.logging.WaarpLoggerFactory;

import java.sql.SQLException;

/**
* Constants value for database
*/
public class DbConstant {
/**
* Internal Logger
*/
private static final WaarpLogger logger =
WaarpLoggerFactory.getLogger(DbConstant.class);
/**
* Illegal value as SpecialId of transfer (any value above is valid)
*/
Expand All @@ -48,4 +59,23 @@ public class DbConstant {
*/
public static final int DELAYMAXCONNECTION = 30;

/**
* Print the error from SQLException
*
* @param ex
*/
public static void error(final SQLException ex) {
// handle any errors
logger.error(
"SQLException: " + ex.getMessage() + " SQLState: " + ex.getSQLState() +
" VendorError: " + ex.getErrorCode());
}

/**
* @return True if Db is used
*/
public static boolean isDbUsed() {
return admin != null && admin.getTypeDriver() != null &&
admin.getTypeDriver() != DbType.none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public DbPreparedStatement(final DbSession ls, final String request)
} catch (final SQLException e1) {
logger.error("SQL Exception PreparedStatement: " + request + ' ' +
e.getMessage());
DbSession.error(e);
DbConstant.error(e);
preparedStatement = null;
setReady(false);
throw new WaarpDatabaseSqlException("SQL Exception PreparedStatement",
Expand Down Expand Up @@ -188,7 +188,7 @@ public DbPreparedStatement(final DbSession ls, final String request,
} catch (final SQLException e1) {
logger.error("SQL Exception PreparedStatement: " + request + ' ' +
e.getMessage());
DbSession.error(e);
DbConstant.error(e);
preparedStatement = null;
setReady(false);
throw new WaarpDatabaseSqlException("SQL Exception PreparedStatement",
Expand Down Expand Up @@ -236,7 +236,7 @@ public final void createPrepareStatement(final String requestarg)
logger.error(
"SQL Exception createPreparedStatement from {}:" + requestarg +
' ' + e.getMessage(), ls.getAdmin().getServer());
DbSession.error(e);
DbConstant.error(e);
realClose();
preparedStatement = null;
setReady(false);
Expand Down Expand Up @@ -285,7 +285,7 @@ public final void executeQuery()
} catch (final SQLException e) {
logger.error(
"SQL Exception executeQuery:" + request + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
close();
rs = null;
ls.checkConnectionNoException();
Expand Down Expand Up @@ -324,7 +324,7 @@ public final int executeUpdate()
logger.error(
"SQL Exception executeUpdate:" + request + ' ' + e.getMessage());
logger.debug("SQL Exception full stack trace", e);
DbSession.error(e);
DbConstant.error(e);
ls.checkConnectionNoException();
throw new WaarpDatabaseSqlException(
"SQL Exception executeUpdate: " + request, e);
Expand Down Expand Up @@ -391,7 +391,7 @@ public final boolean getNext()
logger.error("SQL Exception to getNextRow" +
(request != null? " [" + request + ']' : "") + ' ' +
e.getMessage());
DbSession.error(e);
DbConstant.error(e);
ls.checkConnectionNoException();
throw new WaarpDatabaseSqlException(
"SQL Exception to getNextRow: " + request, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public final void select(final String select)
}
} catch (final SQLException e) {
logger.error(SQL_EXCEPTION_REQUEST + select + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
ls.checkConnectionNoException();
throw new WaarpDatabaseSqlException(SQL_EXCEPTION_REQUEST1 + select, e);
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public final void select(final String select, final int timeout)
}
} catch (final SQLException e) {
logger.error(SQL_EXCEPTION_REQUEST1 + select + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
ls.checkConnectionNoException();
throw new WaarpDatabaseSqlException(SQL_EXCEPTION_REQUEST1 + select, e);
}
Expand Down Expand Up @@ -192,7 +192,7 @@ public final int query(final String query)
return rowcount;
} catch (final SQLException e) {
logger.error(SQL_EXCEPTION_REQUEST1 + query + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
ls.checkConnectionNoException();
throw new WaarpDatabaseSqlException(SQL_EXCEPTION_REQUEST1 + query, e);
}
Expand Down Expand Up @@ -242,7 +242,7 @@ public final long getLastId() throws WaarpDatabaseNoDataException {
result = rstmp.getLong(1);
}
} catch (final SQLException e) {
DbSession.error(e);
DbConstant.error(e);
ls.checkConnectionNoException();
throw new WaarpDatabaseNoDataException("No data found", e);
} finally {
Expand Down Expand Up @@ -281,7 +281,7 @@ public final boolean getNext()
return rs.next();
} catch (final SQLException e) {
logger.warn("SQL Exception to getNextRow" + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
ls.checkConnectionNoException();
throw new WaarpDatabaseSqlException("SQL Exception to getNextRow", e);
}
Expand Down
28 changes: 8 additions & 20 deletions WaarpCommon/src/main/java/org/waarp/common/database/DbSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void initialize(final DbModel dbModel, final String server,
// handle any errors
logger.error(CANNOT_CREATE_CONNECTION + " while already having {}",
DbAdmin.getNbConnection());
error(ex);
DbConstant.error(ex);
if (getConn() != null) {
try {
getConn().close();
Expand Down Expand Up @@ -226,7 +226,7 @@ public final void setAutoCommit(final boolean autoCommit)
// handle any errors
logger.error(CANNOT_CREATE_CONNECTION + " while already having {}",
DbAdmin.getNbConnection());
error(e);
DbConstant.error(e);
if (getConn() != null) {
try {
getConn().close();
Expand Down Expand Up @@ -256,18 +256,6 @@ protected final void setAdmin(final DbAdmin admin) {
this.admin = admin;
}

/**
* Print the error from SQLException
*
* @param ex
*/
public static void error(final SQLException ex) {
// handle any errors
logger.error(
"SQLException: " + ex.getMessage() + " SQLState: " + ex.getSQLState() +
" VendorError: " + ex.getErrorCode());
}

/**
* To be called when a client will start to use this DbSession (once by
* client)
Expand Down Expand Up @@ -373,7 +361,7 @@ public final void forceDisconnect() {
}
} catch (final SQLException e) {
logger.warn("Disconnection not OK");
error(e);
DbConstant.error(e);
} catch (final ConcurrentModificationException e) {
// ignore
}
Expand Down Expand Up @@ -410,7 +398,7 @@ public final void disconnect() {
}
} catch (final SQLException e) {
logger.warn("Disconnection not OK");
error(e);
DbConstant.error(e);
} catch (final ConcurrentModificationException e) {
// ignore
}
Expand Down Expand Up @@ -538,7 +526,7 @@ public final void commit()
getConn().commit();
} catch (final SQLException e) {
logger.error("Cannot Commit");
error(e);
DbConstant.error(e);
throw new WaarpDatabaseSqlException("Cannot commit", e);
}
}
Expand Down Expand Up @@ -569,7 +557,7 @@ public final void rollback(final Savepoint savepoint)
}
} catch (final SQLException e) {
logger.error("Cannot rollback");
error(e);
DbConstant.error(e);
throw new WaarpDatabaseSqlException("Cannot rollback", e);
}
}
Expand All @@ -596,7 +584,7 @@ public final Savepoint savepoint()
return getConn().setSavepoint();
} catch (final SQLException e) {
logger.error("Cannot savepoint");
error(e);
DbConstant.error(e);
throw new WaarpDatabaseSqlException("Cannot savepoint", e);
}
}
Expand All @@ -623,7 +611,7 @@ public final void releaseSavepoint(final Savepoint savepoint)
getConn().releaseSavepoint(savepoint);
} catch (final SQLException e) {
logger.error("Cannot release savepoint");
error(e);
DbConstant.error(e);
throw new WaarpDatabaseSqlException("Cannot release savepoint", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.waarp.common.database.DbConstant;
import org.waarp.common.database.DbPreparedStatement;
import org.waarp.common.database.DbSession;
import org.waarp.common.database.exception.WaarpDatabaseException;
Expand Down Expand Up @@ -512,7 +513,7 @@ public static void setTrueValue(final PreparedStatement ps,
throw new WaarpDatabaseSqlException(
"Setting values casting error: " + value.type + " at " + rank, e);
} catch (final SQLException e) {
DbSession.error(e);
DbConstant.error(e);
throw new WaarpDatabaseSqlException(
"Setting values in error: " + value.type + " at " + rank, e);
}
Expand Down Expand Up @@ -596,7 +597,7 @@ public static void getTrueValue(final ResultSet rs, final DbValue value)
value.getColumn());
}
} catch (final SQLException e) {
DbSession.error(e);
DbConstant.error(e);
throw new WaarpDatabaseSqlException(
"Getting values in error: " + value.type + " for " +
value.getColumn(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected DbModelH2() throws WaarpDatabaseNoConnectionException {
// SQLException
logger.error(
"Cannot register Driver " + type.name() + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
throw new WaarpDatabaseNoConnectionException(
"Cannot load database drive:" + type.name(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected DbModelMariadb() throws WaarpDatabaseNoConnectionException {
// SQLException
logger.error(
"Cannot register Driver " + type.name() + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
throw new WaarpDatabaseNoConnectionException(
"Cannot load database drive:" + type.name(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.netty.util.internal.PlatformDependent;
import org.waarp.common.database.DbAdmin;
import org.waarp.common.database.DbConnectionPool;
import org.waarp.common.database.DbSession;
import org.waarp.common.database.DbConstant;
import org.waarp.common.database.exception.WaarpDatabaseNoConnectionException;
import org.waarp.common.logging.SysErrLogger;
import org.waarp.common.logging.WaarpLogger;
Expand Down Expand Up @@ -216,7 +216,7 @@ protected DbModelMysql() throws WaarpDatabaseNoConnectionException {
// SQLException
logger.error(
"Cannot register Driver " + type.name() + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
throw new WaarpDatabaseNoConnectionException(
"Cannot load database drive:" + type.name(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected DbModelOracle() throws WaarpDatabaseNoConnectionException {
// SQLException
logger.error(
"Cannot register Driver " + type.name() + ' ' + e.getMessage());
DbSession.error(e);
DbConstant.error(e);
throw new WaarpDatabaseNoConnectionException(
"Cannot load database drive:" + type.name(), e);
}
Expand Down
Loading

0 comments on commit 3244684

Please sign in to comment.