Skip to content

Commit

Permalink
Cleaning code
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericBregier committed Sep 30, 2020
1 parent e1309ba commit 2b6b4f2
Show file tree
Hide file tree
Showing 194 changed files with 2,224 additions and 2,532 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ private class R66AdminGuiActions extends SwingWorker<String, Integer> {
}

@Override
protected String doInBackground() throws Exception {
protected String doInBackground() {
disableAllButtons();
startRequest();
switch (method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AesManager extends KeyManager {
/**
* @return the current KeyManager
*/
public static final KeyManager getInstance() {
public static KeyManager getInstance() {
return manager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BlowfishManager extends KeyManager {
/**
* @return the current KeyManager
*/
public static final KeyManager getInstance() {
public static KeyManager getInstance() {
return manager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DynamicKeyManager extends KeyManager {
/**
* @return the current KeyManager
*/
public static final KeyManager getInstance() {
public static KeyManager getInstance() {
return manager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class HmacSha1Manager extends KeyManager {
/**
* @return the current KeyManager
*/
public static final KeyManager getInstance() {
public static KeyManager getInstance() {
return manager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class HmacSha256Manager extends KeyManager {
/**
* @return the current KeyManager
*/
public static final KeyManager getInstance() {
public static KeyManager getInstance() {
return manager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public final class WaarpSslUtility {
new ChannelFutureListener() {

@Override
public void operationComplete(final ChannelFuture future)
throws Exception {
public void operationComplete(final ChannelFuture future) {
if (future.channel().isActive()) {
final SslThread thread = new SslThread(future.channel());
thread.start();
Expand Down Expand Up @@ -110,7 +109,7 @@ public static void addSslHandler(final ChannelFuture future,
} else {
future.addListener(new GenericFutureListener() {
@Override
public void operationComplete(final Future future) throws Exception {
public void operationComplete(final Future future) {
logger.debug("Add SslHandler: {}", pipeline.channel());
pipeline.addFirst("SSL", sslHandler);
((SslHandler) sslHandler).handshakeFuture().addListener(listener);
Expand Down Expand Up @@ -225,8 +224,7 @@ public static void removingSslHandler(final ChannelFuture future,
if (future != null) {
future.addListener(new GenericFutureListener() {
@Override
public void operationComplete(final Future future)
throws Exception {
public void operationComplete(final Future future) {
waitForSslClose(channel, sslHandler, close);
}
});
Expand All @@ -250,8 +248,7 @@ private static void waitForSslClose(final Channel channel,
cht.close()
.addListener(new GenericFutureListener<Future<? super Void>>() {
@Override
public void operationComplete(final Future<? super Void> future)
throws Exception {
public void operationComplete(final Future<? super Void> future) {
logger.debug("Ssl closed: {}", channel);
if (!close) {
channel.pipeline().remove(sslHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public WaarpX509TrustManager() {
public WaarpX509TrustManager(final TrustManagerFactory tmf)
throws CryptoException {
final TrustManager[] tms = tmf.getTrustManagers();
/**
/*
* Iterate over the returned trustmanagers, look for an instance of X509TrustManager and use it as the default
*/
for (final TrustManager tm : tms) {
Expand All @@ -66,7 +66,7 @@ public WaarpX509TrustManager(final TrustManagerFactory tmf)
return;
}
}
/**
/*
* Could not initialize, maybe try to build it from scratch?
*/
throw new CryptoException("Cannot initialize the WaarpX509TrustManager");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
/**
* Class for access to Database
*
* Partially deprecated (only in Waarp R66 but not other components)
* Partially deprecated (only in Waarp R66, except Rest, Http and Monitoring
* and special cases using PreparedStatements but not other components)
*/
public class DbAdmin {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private TryDisconnectDbSession(final DbSession dbSession) {
}

@Override
public void run(final Timeout timeout) throws Exception {
public void run(final Timeout timeout) {
final int val = dbSession.nbThread.get();
if (val <= 0) {
dbSession.disconnect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected void setToArray() {
}

@Override
protected void setFromArray() throws WaarpDatabaseSqlException {
protected void setFromArray() {
hostid = (String) allFields[Columns.HOSTID.ordinal()].getValue();
readgloballimit =
(Long) allFields[Columns.READGLOBALLIMIT.ordinal()].getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,45 +351,51 @@ public String getValueAsString() throws WaarpDatabaseSqlException {
return getValue().toString();
case Types.VARBINARY:
return new String((byte[]) getValue(), WaarpStringUtils.UTF8);
case Types.CLOB: {
final StringBuilder sBuilder = new StringBuilder();
final Reader reader = (Reader) getValue();
final char[] cbuf = new char[4096];
int len;
try {
len = reader.read(cbuf);
while (len > 0) {
sBuilder.append(cbuf, 0, len);
len = reader.read(cbuf);
}
} catch (final IOException e) {
throw new WaarpDatabaseSqlException(
"Error while reading Clob as String", e);
}
return sBuilder.toString();
}
case Types.BLOB: {
final StringBuilder sBuilder = new StringBuilder();
final InputStream inputStream = (InputStream) getValue();
final byte[] cbuf = new byte[4096];
int len;
try {
len = inputStream.read(cbuf);
while (len > 0) {
sBuilder.append(new String(cbuf, 0, len));
len = inputStream.read(cbuf);
}
} catch (final IOException e) {
throw new WaarpDatabaseSqlException(
"Error while reading Blob as String", e);
}
return sBuilder.toString();
}
case Types.CLOB:
return getClob();
case Types.BLOB:
return getBlob();
default:
throw new WaarpDatabaseSqlException(TYPE_UNKNOWN + type);
}
}

private String getBlob() throws WaarpDatabaseSqlException {
final StringBuilder sBuilder = new StringBuilder();
final InputStream inputStream = (InputStream) getValue();
final byte[] cbuf = new byte[4096];
int len;
try {
len = inputStream.read(cbuf);
while (len > 0) {
sBuilder.append(new String(cbuf, 0, len));
len = inputStream.read(cbuf);
}
} catch (final IOException e) {
throw new WaarpDatabaseSqlException("Error while reading Blob as String",
e);
}
return sBuilder.toString();
}

private String getClob() throws WaarpDatabaseSqlException {
final StringBuilder sBuilder = new StringBuilder();
final Reader reader = (Reader) getValue();
final char[] cbuf = new char[4096];
int len;
try {
len = reader.read(cbuf);
while (len > 0) {
sBuilder.append(cbuf, 0, len);
len = reader.read(cbuf);
}
} catch (final IOException e) {
throw new WaarpDatabaseSqlException("Error while reading Clob as String",
e);
}
return sBuilder.toString();
}

public void setValueFromString(final String svalue)
throws WaarpDatabaseSqlException {
switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public abstract class DbModelMysql extends DbModelCommonMariadbMySql {
"com.mysql.cj.jdbc.MysqlConnectionPoolDataSource";
public static final String MYSQL_DRIVER_JRE6 = "com.mysql.jdbc.Driver";
public static final String MYSQL_DRIVER_JRE8 = "com.mysql.cj.jdbc.Driver";
private static final String
CANNOT_INITIALIZE_MYSQL_CONNECTION_POOL_DATA_SOURCE =
"Cannot initialize MysqlConnectionPoolDataSource";

protected static class DbTypeResolverMySQL
extends DbModelAbstract.DbTypeResolver {
Expand Down Expand Up @@ -103,9 +106,9 @@ private ConnectionPoolDataSource createMysqlConnectionPoolDataSource(
mysqlConnectionPoolDataSourceClass =
Class.forName(MYSQL_CONNECTION_POOL_DATA_SOURCE_JRE8);
} catch (final ClassNotFoundException classNotFoundException) {
logger.error("Cannot initialize MysqlConnectionPoolDataSource");
logger.error(CANNOT_INITIALIZE_MYSQL_CONNECTION_POOL_DATA_SOURCE);
throw new WaarpDatabaseNoConnectionException(
"Cannot initialize MysqlConnectionPoolDataSource", e);
CANNOT_INITIALIZE_MYSQL_CONNECTION_POOL_DATA_SOURCE, e);
}
}
try {
Expand All @@ -124,16 +127,16 @@ private ConnectionPoolDataSource createMysqlConnectionPoolDataSource(
return cpds;
} catch (final InstantiationException e) {
throw new WaarpDatabaseNoConnectionException(
"Cannot initialize MysqlConnectionPoolDataSource", e);
CANNOT_INITIALIZE_MYSQL_CONNECTION_POOL_DATA_SOURCE, e);
} catch (final IllegalAccessException e) {
throw new WaarpDatabaseNoConnectionException(
"Cannot initialize MysqlConnectionPoolDataSource", e);
CANNOT_INITIALIZE_MYSQL_CONNECTION_POOL_DATA_SOURCE, e);
} catch (final NoSuchMethodException e) {
throw new WaarpDatabaseNoConnectionException(
"Cannot initialize MysqlConnectionPoolDataSource", e);
CANNOT_INITIALIZE_MYSQL_CONNECTION_POOL_DATA_SOURCE, e);
} catch (final InvocationTargetException e) {
throw new WaarpDatabaseNoConnectionException(
"Cannot initialize MysqlConnectionPoolDataSource", e);
CANNOT_INITIALIZE_MYSQL_CONNECTION_POOL_DATA_SOURCE, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public abstract class AbstractDir implements DirInterface {
*/
protected static final File[] roots;

/**
/*
* Init Windows Support
*/
static {
Expand Down Expand Up @@ -359,7 +359,7 @@ protected abstract List<String> wildcardFiles(String pathWithWildcard)
throws CommandAbstractException;

@Override
public String getPwd() throws CommandAbstractException {
public String getPwd() {
return currentDir;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ public void setBlock(final byte[] block) {
if (isRESTART) {
this.block = null;
markers = new int[6];
System.arraycopy(block, 0, markers, 0, 6);
for (int i = 0; i < 6; i++) {
markers[i] = block[i];
}
byteCount = 6;
return;
}
Expand Down
Loading

0 comments on commit 2b6b4f2

Please sign in to comment.