From 653253f53bc64bab3c8a093714129e1658764161 Mon Sep 17 00:00:00 2001 From: Kirill Liubun Date: Tue, 27 Sep 2016 17:50:36 +0300 Subject: [PATCH] CatchParameterName fix --- .../org/kaaproject/kaa/avro/avrogen/Main.java | 7 +- .../kaa/avro/avrogen/compiler/Compiler.java | 26 ++--- .../logging/AndroidSQLiteDBLogStorage.java | 70 ++++++------ .../kaa/client/AbstractKaaClient.java | 24 ++-- .../java/org/kaaproject/kaa/client/Kaa.java | 12 +- .../kaa/client/KaaClientProperties.java | 4 +- .../bootstrap/DefaultBootstrapManager.java | 8 +- .../kaa/client/channel/IPTransportInfo.java | 6 +- .../channel/impl/DefaultChannelManager.java | 4 +- .../channels/DefaultBootstrapChannel.java | 6 +- .../channels/DefaultOperationHttpChannel.java | 10 +- .../channels/DefaultOperationTcpChannel.java | 32 +++--- .../channels/DefaultOperationsChannel.java | 10 +- .../polling/CancelableCommandRunnable.java | 2 +- .../impl/channels/polling/PollCommand.java | 4 +- .../transports/DefaultEventTransport.java | 4 +- .../impl/transports/DefaultLogTransport.java | 4 +- .../base/AbstractConfigurationManager.java | 8 +- .../base/ResyncConfigurationManager.java | 4 +- .../context/AbstractExecutorContext.java | 4 +- .../kaa/client/event/DefaultEventManager.java | 10 +- .../client/logging/DefaultLogCollector.java | 4 +- .../logging/future/ExecutionResult.java | 14 +-- .../client/logging/future/RecordFuture.java | 4 +- .../DefaultNotificationManager.java | 8 +- .../persistence/KaaClientPropertiesState.java | 52 ++++----- .../DefaultSchemaPersistenceManager.java | 4 +- .../client/transport/TransportException.java | 4 +- .../DefaultBootstrapManagerTest.java | 4 +- .../channel/DefaultBootstrapChannelTest.java | 4 +- .../channel/DefaultEventTransportTest.java | 8 +- .../channel/DefaultOperationsChannelTest.java | 4 +- .../kaa/client/common/DefaultCommonTest.java | 4 +- ...efaultEndpointRegistrationManagerTest.java | 4 +- .../DefaultSchemaPersistenceManagerTest.java | 6 +- .../connectivity/PingConnectivityChecker.java | 4 +- .../logging/DesktopSQLiteDBLogStorage.java | 96 ++++++++-------- .../common/core/algorithms/AvroUtils.java | 2 +- .../DefaultRecordGenerationAlgorithmImpl.java | 6 +- .../override/DefaultOverrideAlgorithm.java | 8 +- .../kaa/common/avro/GenericAvroConverter.java | 12 +- .../protocols/kaatcp/messages/MqttFrame.java | 6 +- .../kaa/common/endpoint/security/KeyUtil.java | 54 ++++----- .../security/MessageEncoderDecoder.java | 12 +- .../kaa/common/hash/SHA1HashUtils.java | 4 +- ...HttpComponentsRequestFactoryBasicAuth.java | 2 +- .../server/common/admin/KaaRestTemplate.java | 8 +- .../kaa/server/common/admin/TestMessage.java | 8 +- .../kaa/server/common/dao/impl/DaoUtil.java | 4 +- .../dao/impl/sql/HibernateAbstractDao.java | 2 +- .../common/dao/model/sql/ModelUtils.java | 14 +-- .../dao/schema/EventSchemaProcessorImpl.java | 10 +- .../common/dao/service/CTLServiceImpl.java | 16 +-- .../common/dao/service/SdkTokenGenerator.java | 4 +- .../service/UserConfigurationServiceImpl.java | 4 +- .../server/common/dao/service/Validator.java | 4 +- .../kaa/server/common/dao/AbstractTest.java | 58 +++++----- .../dao/impl/sql/HibernateAbstractTest.java | 22 ++-- .../cli/client/BaseCliThriftClient.java | 22 ++-- .../cli/server/BaseCliThriftService.java | 20 ++-- .../common/thrift/util/ThriftClient.java | 4 +- .../server/common/zk/ControlNodeTracker.java | 18 +-- .../server/common/zk/WorkerNodeTracker.java | 22 ++-- .../server/common/zk/control/ControlNode.java | 10 +- .../services/ConfigurationServiceImpl.java | 104 +++++++++--------- .../services/NotificationServiceImpl.java | 80 +++++++------- .../admin/services/ProfileServiceImpl.java | 102 ++++++++--------- 67 files changed, 565 insertions(+), 560 deletions(-) diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/Main.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/Main.java index f4e476b137..fd8b236ed0 100644 --- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/Main.java +++ b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/Main.java @@ -18,6 +18,7 @@ import org.kaaproject.kaa.avro.avrogen.compiler.ObjectiveCCompiler; +import org.kaaproject.kaa.avro.avrogen.compiler.Compiler; public class Main { public static void main(String[] args) { @@ -27,10 +28,10 @@ public static void main(String[] args) { + "Need {FULL_PATH_TO_SCHEMA} {OUTPUT_PATH} {SOURCE_NAME}"); } - org.kaaproject.kaa.avro.avrogen.compiler.Compiler compiler = new ObjectiveCCompiler(args[0], args[1], args[2]); + Compiler compiler = new ObjectiveCCompiler(args[0], args[1], args[2]); compiler.generate(); - } catch (Exception e) { - System.err.println("Compilation failure: " + e.toString()); + } catch (Exception ex) { + System.err.println("Compilation failure: " + ex.toString()); } } } diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/Compiler.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/Compiler.java index bb779e5530..2fcb4fc448 100644 --- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/Compiler.java +++ b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/Compiler.java @@ -106,16 +106,16 @@ public Compiler(String schemaPath, String outputPath, String sourceName) throws String headerPath = outputPath + File.separator + generatedSourceName + ".h"; String sourcePath = outputPath + File.separator + generatedSourceName + getSourceExtension(); - Files.move(new File(headerTemplateGen()).toPath() - , new File(headerPath).toPath(), StandardCopyOption.REPLACE_EXISTING); - Files.move(new File(sourceTemplateGen()).toPath() - , new File(sourcePath).toPath(), StandardCopyOption.REPLACE_EXISTING); + Files.move(new File(headerTemplateGen()).toPath(), + new File(headerPath).toPath(), StandardCopyOption.REPLACE_EXISTING); + Files.move(new File(sourceTemplateGen()).toPath(), + new File(sourcePath).toPath(), StandardCopyOption.REPLACE_EXISTING); this.headerWriter = new PrintWriter(new BufferedWriter(new FileWriter(headerPath, true))); this.sourceWriter = new PrintWriter(new BufferedWriter(new FileWriter(sourcePath, true))); - } catch (Exception e) { - LOG.error("Failed to create ouput path: ", e); - throw new KaaGeneratorException("Failed to create output path: " + e.toString()); + } catch (Exception ex) { + LOG.error("Failed to create ouput path: ", ex); + throw new KaaGeneratorException("Failed to create output path: " + ex.toString()); } } @@ -158,9 +158,9 @@ private void prepareTemplates(boolean toFile) throws KaaGeneratorException { } else { writeToStream(hdrWriter, srcWriter); } - } catch (Exception e) { - LOG.error("Failed to prepare source templates: ", e); - throw new KaaGeneratorException("Failed to prepare source templates: " + e.toString()); + } catch (Exception ex) { + LOG.error("Failed to prepare source templates: ", ex); + throw new KaaGeneratorException("Failed to prepare source templates: " + ex.toString()); } } @@ -199,9 +199,9 @@ public Set generate() throws KaaGeneratorException { LOG.debug("Sources were successfully generated"); return schemaGenerationQueue.keySet(); - } catch (Exception e) { - LOG.error("Failed to generate C sources: ", e); - throw new KaaGeneratorException("Failed to generate sources: " + e.toString()); + } catch (Exception ex) { + LOG.error("Failed to generate C sources: ", ex); + throw new KaaGeneratorException("Failed to generate sources: " + ex.toString()); } finally { headerWriter.close(); sourceWriter.close(); diff --git a/client/client-multi/client-java-android/src/main/java/org/kaaproject/kaa/client/logging/AndroidSQLiteDBLogStorage.java b/client/client-multi/client-java-android/src/main/java/org/kaaproject/kaa/client/logging/AndroidSQLiteDBLogStorage.java index 096e63922d..ef7e7cc0df 100644 --- a/client/client-multi/client-java-android/src/main/java/org/kaaproject/kaa/client/logging/AndroidSQLiteDBLogStorage.java +++ b/client/client-multi/client-java-android/src/main/java/org/kaaproject/kaa/client/logging/AndroidSQLiteDBLogStorage.java @@ -83,9 +83,9 @@ public BucketInfo addLogRecord(LogRecord record) { if (insertStatement == null) { try { insertStatement = database.compileStatement(PersistentLogStorageConstants.KAA_INSERT_NEW_RECORD); - } catch (SQLiteException e) { - Log.e(TAG, "Can't create row insert statement", e); - throw new RuntimeException(e); + } catch (SQLiteException ex) { + Log.e(TAG, "Can't create row insert statement", ex); + throw new RuntimeException(ex); } } long leftConsumedSize = maxBucketSize - currentBucketSize; @@ -136,13 +136,13 @@ public LogBucket getNextBucket() { if (cursor.moveToFirst()) { bucketId = cursor.getInt(0); } - } catch (SQLiteException e) { - Log.e(TAG, "Can't retrieve min bucket ID", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Can't retrieve min bucket ID", ex); } finally { try { tryCloseCursor(cursor); - } catch (SQLiteException e) { - Log.e(TAG, "Unable to close cursor", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Unable to close cursor", ex); } } @@ -178,13 +178,13 @@ public LogBucket getNextBucket() { Log.i(TAG, "No unmarked log records found"); } } - } catch (SQLiteException e) { - Log.e(TAG, "Can't retrieve unmarked records from storage", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Can't retrieve unmarked records from storage", ex); } finally { try { tryCloseCursor(cursor); - } catch (SQLiteException e) { - Log.e(TAG, "Unable to close cursor", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Unable to close cursor", ex); } } return logBlock; @@ -210,8 +210,8 @@ private void updateBucketState(int bucketId) { Log.w(TAG, "No log records were updated"); } - } catch (SQLiteException e) { - Log.e(TAG, "Failed to update state for bucket [" + bucketId + "]", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Failed to update state for bucket [" + bucketId + "]", ex); } } } @@ -223,9 +223,9 @@ public void removeBucket(int recordBlockId) { if (deleteByBucketIdStatement == null) { try { deleteByBucketIdStatement = database.compileStatement(PersistentLogStorageConstants.KAA_DELETE_BY_BUCKET_ID); - } catch (SQLiteException e) { - Log.e(TAG, "Can't create record block deletion statement", e); - throw new RuntimeException(e); + } catch (SQLiteException ex) { + Log.e(TAG, "Can't create record block deletion statement", ex); + throw new RuntimeException(ex); } } @@ -241,8 +241,8 @@ public void removeBucket(int recordBlockId) { } else { Log.i(TAG, "No records were removed from storage"); } - } catch (SQLiteException e) { - Log.e(TAG, "Failed to remove record block with id [" + recordBlockId + "]", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Failed to remove record block with id [" + recordBlockId + "]", ex); } } } @@ -254,9 +254,9 @@ public void rollbackBucket(int bucketId) { if (resetBucketIdStatement == null) { try { resetBucketIdStatement = database.compileStatement(PersistentLogStorageConstants.KAA_RESET_BY_BUCKET_ID); - } catch (SQLiteException e) { - Log.e(TAG, "Can't create bucket id reset statement", e); - throw new RuntimeException(e); + } catch (SQLiteException ex) { + Log.e(TAG, "Can't create bucket id reset statement", ex); + throw new RuntimeException(ex); } } @@ -274,8 +274,8 @@ public void rollbackBucket(int bucketId) { Log.i(TAG, "No log records for bucket with id: [" + bucketId + "]"); } - } catch (SQLiteException e) { - Log.e(TAG, "Failed to reset bucket with id [" + bucketId + "]", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Failed to reset bucket with id [" + bucketId + "]", ex); } } } @@ -325,14 +325,14 @@ private void retrieveBucketId() { this.currentBucketId = ++currentBucketId; } - } catch (SQLiteException e) { - Log.e(TAG, "Can't create select max bucket ID statement", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Can't create select max bucket ID statement", ex); throw new RuntimeException("Can't create select max bucket ID statement"); } finally { try { tryCloseCursor(cursor); - } catch (SQLiteException e) { - Log.e(TAG, "Unable to close cursor", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Unable to close cursor", ex); } } } @@ -366,8 +366,8 @@ private void truncateIfBucketSizeIncompatible() { if (cursor.moveToFirst()) { lastSavedBucketSize = cursor.getInt(0); } - } catch (SQLiteException e) { - Log.e(TAG, "Cannot retrieve storage param: bucketSize", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Cannot retrieve storage param: bucketSize", ex); throw new RuntimeException("Cannot retrieve storage param: bucketSize"); } finally { tryCloseCursor(cursor); @@ -379,8 +379,8 @@ private void truncateIfBucketSizeIncompatible() { if (cursor.moveToFirst()) { lastSavedRecordCount = cursor.getInt(0); } - } catch (SQLiteException e) { - Log.e(TAG, "Cannot retrieve storage param: recordCount", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Cannot retrieve storage param: recordCount", ex); throw new RuntimeException("Cannot retrieve storage param: recordCount"); } finally { tryCloseCursor(cursor); @@ -390,8 +390,8 @@ private void truncateIfBucketSizeIncompatible() { if (lastSavedBucketSize != maxBucketSize || lastSavedRecordCount != maxRecordCount) { database.execSQL(PersistentLogStorageConstants.KAA_DELETE_ALL_DATA); } - } catch (SQLiteException e) { - Log.e(TAG, "Can't prepare delete statement", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Can't prepare delete statement", ex); throw new RuntimeException("Can't prepare delete statement"); } finally { tryCloseCursor(cursor); @@ -411,8 +411,8 @@ private void updateStorageParams() { updateInfoStatement.bindString(1, PersistentLogStorageConstants.STORAGE_RECORD_COUNT); updateInfoStatement.bindLong(2, maxRecordCount); updateInfoStatement.execute(); - } catch (SQLiteException e) { - Log.e(TAG, "Can't prepare update storage info statement", e); + } catch (SQLiteException ex) { + Log.e(TAG, "Can't prepare update storage info statement", ex); throw new RuntimeException("Can't prepare update storage info statement"); } finally { tryCloseStatement(updateInfoStatement); diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/AbstractKaaClient.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/AbstractKaaClient.java index 51cb105193..dc55eb51e0 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/AbstractKaaClient.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/AbstractKaaClient.java @@ -246,15 +246,15 @@ public void run() { if (stateListener != null) { stateListener.onStarted(); } - } catch (TransportException e) { - LOG.error("Start failed", e); + } catch (TransportException ex) { + LOG.error("Start failed", ex); if (stateListener != null) { - stateListener.onStartFailure(new KaaClusterConnectionException(e)); + stateListener.onStartFailure(new KaaClusterConnectionException(ex)); } - } catch (KaaRuntimeException e) { - LOG.error("Start failed", e); + } catch (KaaRuntimeException ex) { + LOG.error("Start failed", ex); if (stateListener != null) { - stateListener.onStartFailure(new KaaException(e)); + stateListener.onStartFailure(new KaaException(ex)); } } } @@ -317,10 +317,10 @@ public void run() { if (stateListener != null) { stateListener.onPaused(); } - } catch (Exception e) { - LOG.error("Pause failed", e); + } catch (Exception ex) { + LOG.error("Pause failed", ex); if (stateListener != null) { - stateListener.onPauseFailure(new KaaException(e)); + stateListener.onPauseFailure(new KaaException(ex)); } } } @@ -342,10 +342,10 @@ public void run() { if (stateListener != null) { stateListener.onResume(); } - } catch (Exception e) { - LOG.error("Resume failed", e); + } catch (Exception ex) { + LOG.error("Resume failed", ex); if (stateListener != null) { - stateListener.onResumeFailure(new KaaException(e)); + stateListener.onResumeFailure(new KaaException(ex)); } } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/Kaa.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/Kaa.java index 41f72f644b..9eeb31ec49 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/Kaa.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/Kaa.java @@ -53,12 +53,12 @@ public static KaaClient newClient(KaaClientPlatformContext context, KaaClientSta boolean isAutogeneratedKeys) throws KaaRuntimeException { try { return new BaseKaaClient(context, listener, isAutogeneratedKeys); - } catch (GeneralSecurityException e) { - LOG.error("Failed to create Kaa client", e); - throw new KaaUnsupportedPlatformException(e); - } catch (IOException e) { - LOG.error("Failed to create Kaa client", e); - throw new KaaInvalidConfigurationException(e); + } catch (GeneralSecurityException ex) { + LOG.error("Failed to create Kaa client", ex); + throw new KaaUnsupportedPlatformException(ex); + } catch (IOException ex) { + LOG.error("Failed to create Kaa client", ex); + throw new KaaInvalidConfigurationException(ex); } } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/KaaClientProperties.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/KaaClientProperties.java index 7c35e6f394..a0f88f5fde 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/KaaClientProperties.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/KaaClientProperties.java @@ -118,8 +118,8 @@ public byte[] getPropertiesHash() { updateDigest(digest, SDK_TOKEN); propertiesHash = digest.digest(); - } catch (NoSuchAlgorithmException e) { - LOG.warn("Failed to calculate hash for SDK properties: {}", e); + } catch (NoSuchAlgorithmException ex) { + LOG.warn("Failed to calculate hash for SDK properties: {}", ex); } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/bootstrap/DefaultBootstrapManager.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/bootstrap/DefaultBootstrapManager.java index 2b52da498b..cecb804ed4 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/bootstrap/DefaultBootstrapManager.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/bootstrap/DefaultBootstrapManager.java @@ -199,8 +199,8 @@ private void resolveFailoverStatus(FailoverStatus status) { public void run() { try { receiveOperationsServerList(); - } catch (TransportException e) { - LOG.error("Error while receiving operations service list", e); + } catch (TransportException ex) { + LOG.error("Error while receiving operations service list", ex); } } }, retryPeriod, TimeUnit.MILLISECONDS); @@ -214,8 +214,8 @@ public void run() { public void run() { try { receiveOperationsServerList(); - } catch (TransportException e) { - LOG.error("Error while receiving operations service list", e); + } catch (TransportException ex) { + LOG.error("Error while receiving operations service list", ex); } } }, retryPeriod, TimeUnit.MILLISECONDS); diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/IPTransportInfo.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/IPTransportInfo.java index 5b315fa666..fcf04cda3f 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/IPTransportInfo.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/IPTransportInfo.java @@ -44,9 +44,9 @@ public IPTransportInfo(TransportConnectionInfo parent) { buf.get(publicKeyData); try { this.publicKey = KeyUtil.getPublic(publicKeyData); - } catch (InvalidKeyException e) { - LOG.error("Can't initialize public key", e); - throw new RuntimeException(e); + } catch (InvalidKeyException ex) { + LOG.error("Can't initialize public key", ex); + throw new RuntimeException(ex); } byte[] hostData = new byte[buf.getInt()]; buf.get(hostData); diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/DefaultChannelManager.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/DefaultChannelManager.java index 013a6f3016..29a041de05 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/DefaultChannelManager.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/DefaultChannelManager.java @@ -535,11 +535,11 @@ public void run() { LOG.debug("[{}] Going to invoke sync method", channel.getId()); channel.sync(task.getTypes()); } - } catch (InterruptedException e) { + } catch (InterruptedException ex) { if (stop) { LOG.debug("[{}] Worker is interrupted.", channel.getId()); } else { - LOG.warn("[{}] Worker is interrupted.", channel.getId(), e); + LOG.warn("[{}] Worker is interrupted.", channel.getId(), ex); } } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultBootstrapChannel.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultBootstrapChannel.java index d6b82273a2..07497d7d58 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultBootstrapChannel.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultBootstrapChannel.java @@ -90,12 +90,12 @@ public void run() { try { processTypes(SUPPORTED_TYPES); connectionFailed(false); - } catch (Exception e) { + } catch (Exception ex) { if (!isShutdown()) { - LOG.error("Failed to receive operation servers list {}", e); + LOG.error("Failed to receive operation servers list {}", ex); connectionFailed(true); } else { - LOG.debug("Failed to receive operation servers list {}", e); + LOG.debug("Failed to receive operation servers list {}", ex); } } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationHttpChannel.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationHttpChannel.java index f1dd0deecf..55a8dc8c44 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationHttpChannel.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationHttpChannel.java @@ -96,11 +96,11 @@ public void run() { try { processTypes(typesToProcess); connectionFailed(false); - } catch (TransportException e) { - LOG.error("Failed to receive response from the operation {}", e); - connectionFailed(true, e.getStatus()); - } catch (Exception e) { - LOG.error("Failed to receive response from the operation {}", e); + } catch (TransportException ex) { + LOG.error("Failed to receive response from the operation {}", ex); + connectionFailed(true, ex.getStatus()); + } catch (Exception ex) { + LOG.error("Failed to receive response from the operation {}", ex); connectionFailed(true); } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationTcpChannel.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationTcpChannel.java index a517d2ca12..b843627cc5 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationTcpChannel.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationTcpChannel.java @@ -116,9 +116,9 @@ public void onMessage(SyncResponse message) { synchronized (this) { try { resultBody = encDec.decodeData(message.getAvroObject()); - } catch (GeneralSecurityException e) { + } catch (GeneralSecurityException ex) { LOG.error("Failed to decrypt message body for channel [{}]: {}", getId()); - LOG.error("Stack Trace: ", e); + LOG.error("Stack Trace: ", ex); } } } else { @@ -129,8 +129,8 @@ public void onMessage(SyncResponse message) { demultiplexer.preProcess(); demultiplexer.processResponse(resultBody); demultiplexer.postProcess(); - } catch (Exception e) { - LOG.error("Failed to process response for channel [{}]", getId(), e); + } catch (Exception ex) { + LOG.error("Failed to process response for channel [{}]", getId(), ex); } synchronized (DefaultOperationTcpChannel.this) { @@ -198,8 +198,8 @@ public void run() { } else { LOG.info("Can't schedule ping task for channel [{}]. Task was interrupted", getId()); } - } catch (IOException e) { - LOG.error("Failed to send ping request for channel [{}]. Stack trace: ", getId(), e); + } catch (IOException ex) { + LOG.error("Failed to send ping request for channel [{}]. Stack trace: ", getId(), ex); onServerFailed(); } } else { @@ -271,13 +271,13 @@ private synchronized void closeConnection() { LOG.info("Channel \"{}\": closing current connection", getId()); try { sendDisconnect(); - } catch (IOException e) { - LOG.error("Failed to send Disconnect to server: {}", e); + } catch (IOException ex) { + LOG.error("Failed to send Disconnect to server: {}", ex); } finally { try { socket.close(); - } catch (IOException e) { - LOG.error("Failed to close socket: {}", e); + } catch (IOException ex) { + LOG.error("Failed to close socket: {}", ex); } socket = null; messageFactory.getFramer().flush(); @@ -304,8 +304,8 @@ private synchronized void openConnection() { sendConnect(); scheduleReadTask(socket); schedulePingTask(); - } catch (Exception e) { - LOG.error("Failed to create a socket for server {}:{}. Stack trace: ", currentServer.getHost(), currentServer.getPort(), e); + } catch (Exception ex) { + LOG.error("Failed to create a socket for server {}:{}. Stack trace: ", currentServer.getHost(), currentServer.getPort(), ex); onServerFailed(); } } @@ -429,8 +429,8 @@ public synchronized void sync(Set types) { } try { sendKaaSyncRequest(typeMap); - } catch (Exception e) { - LOG.error("Failed to sync channel [{}]", getId(), e); + } catch (Exception ex) { + LOG.error("Failed to sync channel [{}]", getId(), ex); } } @@ -630,10 +630,10 @@ public void run() { onServerFailed(); } - } catch (IOException | KaaTcpProtocolException | RuntimeException e) { + } catch (IOException | KaaTcpProtocolException | RuntimeException ex) { if (Thread.currentThread().isInterrupted()) { if (channelState != State.SHUTDOWN) { - LOG.warn("Socket connection for channel [{}] was interrupted: ", getId(), e); + LOG.warn("Socket connection for channel [{}] was interrupted: ", getId(), ex); } else { LOG.debug("Socket connection for channel [{}] was interrupted.", getId()); } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationsChannel.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationsChannel.java index 60f1a6a164..744ed1843c 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationsChannel.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/channels/DefaultOperationsChannel.java @@ -92,7 +92,7 @@ protected void executeCommand() { while (httpClient == null && !stopped && !Thread.currentThread().isInterrupted()) { try { httpClientSetLock.wait(); - } catch (InterruptedException e) { + } catch (InterruptedException ex) { break; } } @@ -173,8 +173,8 @@ public LinkedHashMap createRequest(Map eventsToCommit = transactions.remove(trxId); synchronized (eventsGuard) { - for (Event e : eventsToCommit) { - e.setSeqNum(state.getAndIncrementEventSeqNum()); - currentEvents.add(e); + for (Event event : eventsToCommit) { + event.setSeqNum(state.getAndIncrementEventSeqNum()); + currentEvents.add(event); } } if (!isEngaged) { @@ -227,8 +227,8 @@ public void rollback(TransactionId trxId) { synchronized (trxGuard) { List eventsToRemove = transactions.remove(trxId); if (eventsToRemove != null) { - for (Event e : eventsToRemove) { - LOG.trace("Removing event {}", e); + for (Event event : eventsToRemove) { + LOG.trace("Removing event {}", event); } } else { LOG.debug("Transaction with id {} was not created", trxId); diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/DefaultLogCollector.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/DefaultLogCollector.java index d22d4987db..3722d401b7 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/DefaultLogCollector.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/DefaultLogCollector.java @@ -53,8 +53,8 @@ public void run() { BucketInfo bucketInfo = storage.addLogRecord(new LogRecord(record)); bucketInfoMap.put(bucketInfo.getBucketId(), bucketInfo); addDeliveryFuture(bucketInfo, future); - } catch (IOException e) { - LOG.warn("Can't serialize log record {}, exception catched: {}", record, e); + } catch (IOException ex) { + LOG.warn("Can't serialize log record {}, exception catched: {}", record, ex); } uploadIfNeeded(); diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/ExecutionResult.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/ExecutionResult.java index 5bee2e259c..d21c9f7045 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/ExecutionResult.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/ExecutionResult.java @@ -18,21 +18,21 @@ public class ExecutionResult { - private final T t; - private final Exception e; + private final T value; + private final Exception exception; - public ExecutionResult(T t, Exception e) { + public ExecutionResult(T value, Exception exception) { super(); - this.t = t; - this.e = e; + this.value = value; + this.exception = exception; } public T get() { - return t; + return value; } public Exception getE() { - return e; + return exception; } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/RecordFuture.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/RecordFuture.java index 974df2626f..8fad324473 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/RecordFuture.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/RecordFuture.java @@ -93,8 +93,8 @@ public void setValue(RecordInfo value, Long arriveTime) { value.setRecordAddedTimestampMs(recordAddedTimestampMs); value.setRecordDeliveryTimeMs(arriveTime - recordAddedTimestampMs); this.queue.put(new ExecutionResult<>(value, null)); - } catch (InterruptedException e) { - LOG.warn("Failed to push value", e); + } catch (InterruptedException ex) { + LOG.warn("Failed to push value", ex); } state = State.DONE; } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/notification/DefaultNotificationManager.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/notification/DefaultNotificationManager.java index adcbaaaa95..42b99aa5a5 100755 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/notification/DefaultNotificationManager.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/notification/DefaultNotificationManager.java @@ -301,8 +301,8 @@ public void notificationReceived(List notifications) throws IOExce notifyListeners(mandatoryListeners, topic, notification); } } - } catch (UnavailableTopicException e) { - LOG.warn("Received notification for an unknown topic (id={}), exception catched: {}", notification.getTopicId(), e); + } catch (UnavailableTopicException ex) { + LOG.warn("Received notification for an unknown topic (id={}), exception catched: {}", notification.getTopicId(), ex); } } } @@ -315,8 +315,8 @@ private void notifyListeners(Collection listeners, final T public void run() { try { deserializer.notify(Collections.unmodifiableCollection(listenersCopy), topic, notification.getBody().array()); - } catch (IOException e) { - LOG.error("Failed to process notification for topic {}", topic.getId(), e); + } catch (IOException ex) { + LOG.error("Failed to process notification for topic {}", topic.getId(), ex); } } }); diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/persistence/KaaClientPropertiesState.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/persistence/KaaClientPropertiesState.java index 9fa4c98422..43d56ca4fd 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/persistence/KaaClientPropertiesState.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/persistence/KaaClientPropertiesState.java @@ -172,7 +172,7 @@ public KaaClientPropertiesState(PersistentStorage storage, Base64 base64, KaaCli Integer eventSeqNum = 0; try { // NOSONAR eventSeqNum = Integer.parseInt(eventSeqNumStr); - } catch (NumberFormatException e) { + } catch (NumberFormatException ex) { LOG.error("Unexpected exception while parsing event sequence number. Can not parse String: {} to Integer", eventSeqNumStr); } @@ -182,14 +182,14 @@ public KaaClientPropertiesState(PersistentStorage storage, Base64 base64, KaaCli if (topicListHashStr != null) { try { // NOSONAR this.topicListHash = Integer.parseInt(topicListHashStr); - } catch (NumberFormatException e) { + } catch (NumberFormatException ex) { LOG.error("Unexpected exception while parsing topic list hash. Can not parse String: {} to Integer", topicListHashStr); } } - } catch (Exception e) { - LOG.error("Can't load state file", e); + } catch (Exception ex) { + LOG.error("Can't load state file", ex); } finally { IOUtils.closeQuietly(stream); } @@ -211,8 +211,8 @@ private void parseTopics() { LOG.debug("Loaded {}", decodedTopic); topicMap.put(decodedTopic.getId(), decodedTopic); } - } catch (Exception e) { - LOG.error("Unexpected exception occurred while reading information from decoder", e); + } catch (Exception ex) { + LOG.error("Unexpected exception occurred while reading information from decoder", ex); } } else { LOG.info("No topic list found in state"); @@ -226,8 +226,8 @@ private void parseNfSubscriptions() { ByteArrayInputStream is = new ByteArrayInputStream(data); try (ObjectInputStream ois = new ObjectInputStream(is)) { nfSubscriptions.putAll((Map) ois.readObject()); - } catch (Exception e) { - LOG.error("Unexpected exception occurred while reading subscription information from state", e); + } catch (Exception ex) { + LOG.error("Unexpected exception occurred while reading subscription information from state", ex); } } else { LOG.info("No subscription info found in state"); @@ -297,8 +297,8 @@ public void persist() { encoder.flush(); String base64Str = new String(base64.encodeBase64(baos.toByteArray()), Charset.forName("UTF-8")); state.setProperty(TOPIC_LIST, base64Str); - } catch (IOException e) { - LOG.error("Can't persist topic list info", e); + } catch (IOException ex) { + LOG.error("Can't persist topic list info", ex); } baos = new ByteArrayOutputStream(); @@ -306,8 +306,8 @@ public void persist() { oos.writeObject(nfSubscriptions); String base64Str = new String(base64.encodeBase64(baos.toByteArray()), Charset.forName("UTF-8")); state.setProperty(NF_SUBSCRIPTIONS, base64Str); - } catch (IOException e) { - LOG.error("Can't persist notification subscription info", e); + } catch (IOException ex) { + LOG.error("Can't persist notification subscription info", ex); } StringBuilder attachedEndpointsString = new StringBuilder(); @@ -326,8 +326,8 @@ public void persist() { os = storage.openForWrite(stateFileLocation); state.store(os, null); hasUpdate = false; - } catch (IOException e) { - LOG.error("Can't persist state file", e); + } catch (IOException ex) { + LOG.error("Can't persist state file", ex); } finally { IOUtils.closeQuietly(os); } @@ -374,12 +374,12 @@ private KeyPair getOrInitKeyPair(boolean isAutogeneratedKeys) { return keyPair; } - } catch (InvalidKeyException e) { + } catch (InvalidKeyException ex) { keyPair = null; - LOG.error("Unable to parse client RSA keypair. Generating new keys.. Reason {}", e); - } catch (Exception e) { - LOG.error("Error loading client RSA keypair. Reason {}", e); - throw new RuntimeException(e); // NOSONAR + LOG.error("Unable to parse client RSA keypair. Generating new keys.. Reason {}", ex); + } catch (Exception ex) { + LOG.error("Error loading client RSA keypair. Reason {}", ex); + throw new RuntimeException(ex); // NOSONAR } finally { IOUtils.closeQuietly(publicKeyInput); IOUtils.closeQuietly(privateKeyInput); @@ -393,9 +393,9 @@ private KeyPair getOrInitKeyPair(boolean isAutogeneratedKeys) { privateKeyOutput = storage.openForWrite(clientPrivateKeyFileLocation); publicKeyOutput = storage.openForWrite(clientPublicKeyFileLocation); keyPair = KeyUtil.generateKeyPair(privateKeyOutput, publicKeyOutput); - } catch (IOException e) { - LOG.error("Error generating Client Key pair", e); - throw new RuntimeException(e); + } catch (IOException ex) { + LOG.error("Error generating Client Key pair", ex); + throw new RuntimeException(ex); } finally { IOUtils.closeQuietly(privateKeyOutput); IOUtils.closeQuietly(publicKeyOutput); @@ -586,10 +586,10 @@ public void clean() { private void saveFileDelete(String fileName) { try { FileUtils.forceDelete(new File(fileName)); - } catch (FileNotFoundException e) { - LOG.trace("File {} wasn't deleted, as it hadn't existed :", fileName, e); - } catch (IOException e) { - LOG.debug("An error occurred during deletion of the file [{}] :", fileName, e); + } catch (FileNotFoundException ex) { + LOG.trace("File {} wasn't deleted, as it hadn't existed :", fileName, ex); + } catch (IOException ex) { + LOG.debug("An error occurred during deletion of the file [{}] :", fileName, ex); } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/schema/storage/DefaultSchemaPersistenceManager.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/schema/storage/DefaultSchemaPersistenceManager.java index fb4943783e..10d9b68f2b 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/schema/storage/DefaultSchemaPersistenceManager.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/schema/storage/DefaultSchemaPersistenceManager.java @@ -61,8 +61,8 @@ public synchronized void onSchemaUpdated(Schema schema) { if (storage != null) { storage.saveSchema(buffer); } - } catch (UnsupportedEncodingException e) { - LOG.error("Failed to save schema: ", e); + } catch (UnsupportedEncodingException ex) { + LOG.error("Failed to save schema: ", ex); throw new SchemaRuntimeException("Failed to save schema"); } } else { diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/transport/TransportException.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/transport/TransportException.java index b9e375f393..58ed48fef1 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/transport/TransportException.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/transport/TransportException.java @@ -28,8 +28,8 @@ public TransportException(String message) { super(message); } - public TransportException(Exception e) { - super(e); + public TransportException(Exception ex) { + super(ex); } public TransportException(int status) { diff --git a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/bootstrap/DefaultBootstrapManagerTest.java b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/bootstrap/DefaultBootstrapManagerTest.java index 84fad353cb..64990d8194 100644 --- a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/bootstrap/DefaultBootstrapManagerTest.java +++ b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/bootstrap/DefaultBootstrapManagerTest.java @@ -67,7 +67,7 @@ public void testReceiveOperationsServerList() throws TransportException { try { manager.receiveOperationsServerList(); manager.useNextOperationsServer(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, FailoverStatus.NO_CONNECTIVITY); - } catch (BootstrapRuntimeException e) { + } catch (BootstrapRuntimeException ex) { exception = true; } assertTrue(exception); @@ -85,7 +85,7 @@ public void testOperationsServerInfoRetrieving() throws TransportException, NoSu boolean exception = false; try { manager.useNextOperationsServer(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, FailoverStatus.NO_CONNECTIVITY); - } catch (BootstrapRuntimeException e) { + } catch (BootstrapRuntimeException ex) { exception = true; } assertTrue(exception); diff --git a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultBootstrapChannelTest.java b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultBootstrapChannelTest.java index 7eeb51aa34..637d170cde 100644 --- a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultBootstrapChannelTest.java +++ b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultBootstrapChannelTest.java @@ -157,9 +157,9 @@ protected AbstractHttpClient getHttpClient() { MessageEncoderDecoder crypt = Mockito.mock(MessageEncoderDecoder.class); try { Mockito.when(crypt.decodeData(Mockito.any(byte[].class))).thenReturn(new byte[]{5, 5, 5}); - } catch (GeneralSecurityException e) { + } catch (GeneralSecurityException ex) { // TODO Auto-generated catch block - e.printStackTrace(); + ex.printStackTrace(); } Mockito.when(client.getEncoderDecoder()).thenReturn(crypt); diff --git a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultEventTransportTest.java b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultEventTransportTest.java index 8b26eb90e9..a827f9af6d 100644 --- a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultEventTransportTest.java +++ b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultEventTransportTest.java @@ -179,8 +179,8 @@ public void testSychronizedSN() { Assert.assertTrue(eventRequest2.getEvents().size() == events.size()); int expectedEventSN = lastEventSN + 1; - for (Event e : eventRequest2.getEvents()) { - Assert.assertTrue(e.getSeqNum() == expectedEventSN++); + for (Event event : eventRequest2.getEvents()) { + Assert.assertTrue(event.getSeqNum() == expectedEventSN++); } } @@ -217,8 +217,8 @@ public void testSequenceNumberSynchronization() { Assert.assertTrue(eventRequest2.getEvents().size() == events1.size()); int synchronizedSN = lastReceivedSN + 1; - for (Event e : eventRequest2.getEvents()) { - Assert.assertEquals(synchronizedSN++, e.getSeqNum().intValue()); + for (Event event : eventRequest2.getEvents()) { + Assert.assertEquals(synchronizedSN++, event.getSeqNum().intValue()); } transport.onSyncResposeIdReceived(requestId++); diff --git a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultOperationsChannelTest.java b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultOperationsChannelTest.java index ee10a7664e..2d71146f3f 100644 --- a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultOperationsChannelTest.java +++ b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultOperationsChannelTest.java @@ -226,8 +226,8 @@ public void onResponse(byte[] response) { Field field = DefaultOperationsChannel.class.getDeclaredField("stopped"); field.setAccessible(true); field.setBoolean(this, true); - } catch (Exception e) { - throw new AssertionError(e.getMessage()); + } catch (Exception ex) { + throw new AssertionError(ex.getMessage()); } } diff --git a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/common/DefaultCommonTest.java b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/common/DefaultCommonTest.java index 97ca3fea40..98ecf7053c 100644 --- a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/common/DefaultCommonTest.java +++ b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/common/DefaultCommonTest.java @@ -103,8 +103,8 @@ public void testCommonArray() { public void testCommonEnum() { EqualsVerifier.forClass(DefaultCommonEnum.class).verify(); Schema schema = mock(Schema.class); - CommonEnum e = new DefaultCommonEnum(schema, "enum"); - assertEquals(schema, e.getSchema()); + CommonEnum commonEnum = new DefaultCommonEnum(schema, "enum"); + assertEquals(schema, commonEnum.getSchema()); } @Test diff --git a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/event/registration/DefaultEndpointRegistrationManagerTest.java b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/event/registration/DefaultEndpointRegistrationManagerTest.java index 7460e23d31..ce9804f8a2 100644 --- a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/event/registration/DefaultEndpointRegistrationManagerTest.java +++ b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/event/registration/DefaultEndpointRegistrationManagerTest.java @@ -169,8 +169,8 @@ public void checkEndpointAttachDetachResponse() throws Exception { verify(manager, times(2)).onUpdate(anyListOf(EndpointAttachResponse.class), anyListOf(EndpointDetachResponse.class), any(UserAttachResponse.class), any(UserAttachNotification.class), any(UserDetachNotification.class)); verify(listListener, times(1)).onAttachedEndpointListChanged(anyMapOf(EndpointAccessToken.class, EndpointKeyHash.class)); - } catch (IOException e) { - assertTrue("Unexpected exception " + e.getMessage(), false); + } catch (IOException ex) { + assertTrue("Unexpected exception " + ex.getMessage(), false); } } diff --git a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/schema/storage/DefaultSchemaPersistenceManagerTest.java b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/schema/storage/DefaultSchemaPersistenceManagerTest.java index 4932539f79..37ed484838 100644 --- a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/schema/storage/DefaultSchemaPersistenceManagerTest.java +++ b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/schema/storage/DefaultSchemaPersistenceManagerTest.java @@ -46,7 +46,7 @@ public void saveSchema(ByteBuffer buffer) { byte[] expected = null; try { expected = schema.toString().getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException ex) { } assertArrayEquals(expected, buffer.array()); @@ -75,7 +75,7 @@ public void loadSchema(ByteBuffer buffer) throws IOException { byte[] rawBuffer = null; try { rawBuffer = schema.toString().getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException ex) { } assertArrayEquals(rawBuffer, buffer.array()); @@ -99,7 +99,7 @@ public ByteBuffer loadSchema() { byte[] rawBuffer = null; try { rawBuffer = schema.toString().getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException ex) { } ByteBuffer buffer = ByteBuffer.wrap(rawBuffer); diff --git a/client/client-multi/client-java-desktop/src/main/java/org/kaaproject/kaa/client/connectivity/PingConnectivityChecker.java b/client/client-multi/client-java-desktop/src/main/java/org/kaaproject/kaa/client/connectivity/PingConnectivityChecker.java index 74948775a0..561694c66b 100644 --- a/client/client-multi/client-java-desktop/src/main/java/org/kaaproject/kaa/client/connectivity/PingConnectivityChecker.java +++ b/client/client-multi/client-java-desktop/src/main/java/org/kaaproject/kaa/client/connectivity/PingConnectivityChecker.java @@ -46,8 +46,8 @@ public PingConnectivityChecker(String host) { public boolean checkConnectivity() { try { return InetAddress.getByName(host).isReachable(CONNECTION_TIMEOUT_MS); - } catch (IOException e) { - LOG.warn(MessageFormat.format("Host {0} is unreachable", host), e); + } catch (IOException ex) { + LOG.warn(MessageFormat.format("Host {0} is unreachable", host), ex); return false; } } diff --git a/client/client-multi/client-java-desktop/src/main/java/org/kaaproject/kaa/client/logging/DesktopSQLiteDBLogStorage.java b/client/client-multi/client-java-desktop/src/main/java/org/kaaproject/kaa/client/logging/DesktopSQLiteDBLogStorage.java index da41773d0f..23055da800 100644 --- a/client/client-multi/client-java-desktop/src/main/java/org/kaaproject/kaa/client/logging/DesktopSQLiteDBLogStorage.java +++ b/client/client-multi/client-java-desktop/src/main/java/org/kaaproject/kaa/client/logging/DesktopSQLiteDBLogStorage.java @@ -70,12 +70,12 @@ public DesktopSQLiteDBLogStorage(String dbName, long maxBucketSize, int maxRecor retrieveBucketId(); resetBucketIDs(); } - } catch (ClassNotFoundException e) { - LOG.error("Can't find SQLite classes in classpath", e); - throw new RuntimeException(e); - } catch (SQLException e) { - LOG.error("Error while initializing SQLite DB and its tables", e); - throw new RuntimeException(e); + } catch (ClassNotFoundException ex) { + LOG.error("Can't find SQLite classes in classpath", ex); + throw new RuntimeException(ex); + } catch (SQLException ex) { + LOG.error("Error while initializing SQLite DB and its tables", ex); + throw new RuntimeException(ex); } } @@ -86,9 +86,9 @@ public BucketInfo addLogRecord(LogRecord record) { if (insertStatement == null) { try { insertStatement = connection.prepareStatement(PersistentLogStorageConstants.KAA_INSERT_NEW_RECORD); - } catch (SQLException e) { - LOG.error("Can't create row insert statement", e); - throw new RuntimeException(e); + } catch (SQLException ex) { + LOG.error("Can't create row insert statement", ex); + throw new RuntimeException(ex); } } @@ -115,8 +115,8 @@ public BucketInfo addLogRecord(LogRecord record) { } else { LOG.warn("No log record was added"); } - } catch (SQLException e) { - LOG.error("Can't add a new record", e); + } catch (SQLException ex) { + LOG.error("Can't add a new record", ex); } } return new BucketInfo(currentBucketId, currentRecordCount); @@ -144,14 +144,14 @@ public LogBucket getNextBucket() { if (resultSet.next()) { bucketId = resultSet.getInt(1); } - } catch (SQLException e) { - LOG.error("Can't retrieve min bucket ID", e); + } catch (SQLException ex) { + LOG.error("Can't retrieve min bucket ID", ex); } finally { try { tryCloseStatement(selectBucketWithMinIdStatement); tryCloseResultSet(resultSet); - } catch (SQLException e) { - LOG.error("Can't close result set", e); + } catch (SQLException ex) { + LOG.error("Can't close result set", ex); } } @@ -195,13 +195,13 @@ public LogBucket getNextBucket() { } } - } catch (SQLException e) { - LOG.error("Can't retrieve unmarked records from storage", e); + } catch (SQLException ex) { + LOG.error("Can't retrieve unmarked records from storage", ex); } finally { try { tryCloseResultSet(resultSet); - } catch (SQLException e) { - LOG.error("Can't close result set", e); + } catch (SQLException ex) { + LOG.error("Can't close result set", ex); } } return logBlock; @@ -216,9 +216,9 @@ private void updateBucketState(int bucketId) throws SQLException { try { try { updateBucketStateStatement = connection.prepareStatement(PersistentLogStorageConstants.KAA_UPDATE_BUCKET_ID); - } catch (SQLException e) { - LOG.error("Can't create bucket id update statement", e); - throw new RuntimeException(e); + } catch (SQLException ex) { + LOG.error("Can't create bucket id update statement", ex); + throw new RuntimeException(ex); } try { @@ -230,8 +230,8 @@ private void updateBucketState(int bucketId) throws SQLException { } else { LOG.warn("No log records were updated"); } - } catch (SQLException e) { - LOG.error("Failed to update bucket id [{}]", bucketId, e); + } catch (SQLException ex) { + LOG.error("Failed to update bucket id [{}]", bucketId, ex); } } finally { tryCloseStatement(updateBucketStateStatement); @@ -246,9 +246,9 @@ public void removeBucket(int recordBlockId) { if (deleteByBucketIdStatement == null) { try { deleteByBucketIdStatement = connection.prepareStatement(PersistentLogStorageConstants.KAA_DELETE_BY_BUCKET_ID); - } catch (SQLException e) { - LOG.error("Can't create record block deletion statement", e); - throw new RuntimeException(e); + } catch (SQLException ex) { + LOG.error("Can't create record block deletion statement", ex); + throw new RuntimeException(ex); } } @@ -261,8 +261,8 @@ public void removeBucket(int recordBlockId) { } else { LOG.warn("No records were removed from storage"); } - } catch (SQLException e) { - LOG.error("Failed to remove record block with id [{}]", recordBlockId, e); + } catch (SQLException ex) { + LOG.error("Failed to remove record block with id [{}]", recordBlockId, ex); } } } @@ -274,9 +274,9 @@ public void rollbackBucket(int bucketId) { if (resetBucketIdStatement == null) { try { resetBucketIdStatement = connection.prepareStatement(PersistentLogStorageConstants.KAA_RESET_BY_BUCKET_ID); - } catch (SQLException e) { - LOG.error("Can't create bucket id reset statement", e); - throw new RuntimeException(e); + } catch (SQLException ex) { + LOG.error("Can't create bucket id reset statement", ex); + throw new RuntimeException(ex); } } @@ -292,8 +292,8 @@ public void rollbackBucket(int bucketId) { LOG.info("No log records for bucket with id: [{}]", bucketId); } - } catch (SQLException e) { - LOG.error("Failed to reset bucket with id [{}]", bucketId, e); + } catch (SQLException ex) { + LOG.error("Failed to reset bucket with id [{}]", bucketId, ex); } } } @@ -341,9 +341,9 @@ private void retrieveBucketId() throws SQLException { this.currentBucketId = ++currentBucketId; } - } catch (SQLException e) { - LOG.error("Can't create select max bucket ID statement", e); - throw new RuntimeException(e); + } catch (SQLException ex) { + LOG.error("Can't create select max bucket ID statement", ex); + throw new RuntimeException(ex); } finally { tryCloseResultSet(resultSet); tryCloseStatement(selectBucketWithMaxIdStatement); @@ -410,9 +410,9 @@ private void truncateIfBucketSizeIncompatible() throws SQLException { LOG.warn("No log records were deleted"); } } - } catch (SQLException e) { - LOG.error("Unable to prepare delete statement", e); - throw new RuntimeException(e); + } catch (SQLException ex) { + LOG.error("Unable to prepare delete statement", ex); + throw new RuntimeException(ex); } finally { tryCloseStatement(selectStatement); tryCloseResultSet(resultSet); @@ -439,9 +439,9 @@ private void updateStorageParams() throws SQLException { LOG.info("Storage recordCount was successfully updated: recordCount{}", maxRecordCount); } - } catch (SQLException e) { - LOG.error("Unable to update storage params", e); - throw new RuntimeException(e); + } catch (SQLException ex) { + LOG.error("Unable to update storage params", ex); + throw new RuntimeException(ex); } finally { tryCloseStatement(updateInfoStatement); } @@ -457,8 +457,8 @@ public void close() { if (connection != null) { connection.close(); } - } catch (SQLException e) { - LOG.error("Can't close SQLite db connection", e); + } catch (SQLException ex) { + LOG.error("Can't close SQLite db connection", ex); } } @@ -482,9 +482,9 @@ private void resetBucketIDs() throws SQLException { statement = connection.createStatement(); int updatedRows = statement.executeUpdate(PersistentLogStorageConstants.KAA_RESET_BUCKET_STATE_ON_START); LOG.trace("Number of rows affected: {}", updatedRows); - } catch (SQLException e) { - LOG.error("Can't reset bucket IDs", e); - throw new RuntimeException(e); + } catch (SQLException ex) { + LOG.error("Can't reset bucket IDs", ex); + throw new RuntimeException(ex); } finally { tryCloseStatement(statement); } diff --git a/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtils.java b/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtils.java index ad359d2d33..f512511e93 100644 --- a/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtils.java +++ b/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtils.java @@ -136,7 +136,7 @@ private static JsonNode injectUuidsFromJsonNodes(JsonNode json, Schema schema) { .forEach(s -> injectUuidsFromJsonNodes(json.get(s.getName()), s)); break; case ARRAY: - json.getElements().forEachRemaining((e) -> injectUuids(e, schema.getElementType())); + json.getElements().forEachRemaining((el) -> injectUuids(el, schema.getElementType())); break; default: return json; diff --git a/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/generation/DefaultRecordGenerationAlgorithmImpl.java b/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/generation/DefaultRecordGenerationAlgorithmImpl.java index 8af680b284..53fd857c95 100644 --- a/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/generation/DefaultRecordGenerationAlgorithmImpl.java +++ b/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/generation/DefaultRecordGenerationAlgorithmImpl.java @@ -295,11 +295,11 @@ public final T getRootData() throws IOException, ConfigurationGenerationExceptio GenericAvroConverter converter = new GenericAvroConverter<>(root.getSchema()); try { return dataFactory.createData(rootSchema, converter.encodeToJson(root)); - } catch (RuntimeException e) { + } catch (RuntimeException ex) { // NPE is thrown if "null" was written into a field that is not nullable // CGE is thrown if value of wrong type was written into a field - LOG.error("Unexpected exception occurred while generating configuration.", e); - throw new ConfigurationGenerationException(e); + LOG.error("Unexpected exception occurred while generating configuration.", ex); + throw new ConfigurationGenerationException(ex); } } diff --git a/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/override/DefaultOverrideAlgorithm.java b/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/override/DefaultOverrideAlgorithm.java index 8d91951a07..51c6b90107 100644 --- a/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/override/DefaultOverrideAlgorithm.java +++ b/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/override/DefaultOverrideAlgorithm.java @@ -69,8 +69,8 @@ public BaseData override(BaseData baseConfiguration, List override try { confGenerator = new DefaultRecordGenerationAlgorithmImpl(baseConfiguration.getSchema(), new BaseDataFactory()); - } catch (ConfigurationGenerationException e) { - throw new OverrideException(e); + } catch (ConfigurationGenerationException ex) { + throw new OverrideException(ex); } baseSchemaParser = new Schema.Parser(); @@ -94,8 +94,8 @@ public BaseData override(BaseData baseConfiguration, List override applyNode(mergedConfiguration, nodeToApply, arrayMergeStrategyResolver); } return new BaseData(baseConfiguration.getSchema(), baseConverter.encodeToJson(mergedConfiguration)); - } catch (IOException | ConfigurationGenerationException e) { - throw new OverrideException(e); + } catch (IOException | ConfigurationGenerationException ex) { + throw new OverrideException(ex); } } diff --git a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/avro/GenericAvroConverter.java b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/avro/GenericAvroConverter.java index 9a73e127a8..2894b23033 100644 --- a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/avro/GenericAvroConverter.java +++ b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/avro/GenericAvroConverter.java @@ -93,9 +93,9 @@ public static String toJson(byte[] rawData, String dataSchema) { try { GenericContainer record = converter.decodeBinary(rawData); json = converter.encodeToJson(record); - } catch (IOException e) { - LOG.warn("Can't parse json data", e); - throw new RuntimeException(e); //NOSONAR + } catch (IOException ex) { + LOG.warn("Can't parse json data", ex); + throw new RuntimeException(ex); //NOSONAR } return json; } @@ -116,9 +116,9 @@ public static byte[] toRawData(String json, String dataSchema) { try { GenericContainer record = converter.decodeJson(json); rawData = converter.encode(record); - } catch (IOException e) { - LOG.warn("Can't parse json data", e); - throw new RuntimeException(e); //NOSONAR + } catch (IOException ex) { + LOG.warn("Can't parse json data", ex); + throw new RuntimeException(ex); //NOSONAR } return rawData; } diff --git a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/channels/protocols/kaatcp/messages/MqttFrame.java b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/channels/protocols/kaatcp/messages/MqttFrame.java index 5377092dbd..2ad23d9e29 100644 --- a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/channels/protocols/kaatcp/messages/MqttFrame.java +++ b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/channels/protocols/kaatcp/messages/MqttFrame.java @@ -170,11 +170,11 @@ private void onFrameDone() throws KaaTcpProtocolException { frameDecodeComplete = true; } - private void processByte(byte b) throws KaaTcpProtocolException { + private void processByte(byte value) throws KaaTcpProtocolException { if (currentState.equals(FrameParsingState.PROCESSING_LENGTH)) { - remainingLength += ((b & 0xFF) & 127) * multiplier; + remainingLength += ((value & 0xFF) & 127) * multiplier; multiplier *= 128; - if (((b & 0xFF) & 128) == 0) { + if (((value & 0xFF) & 128) == 0) { LOG.trace("Frame ({}): payload length = {}", getMessageType(), remainingLength); if (remainingLength != 0) { buffer = ByteBuffer.allocate(remainingLength); diff --git a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/endpoint/security/KeyUtil.java b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/endpoint/security/KeyUtil.java index e5878f372a..fe2d4e58a3 100644 --- a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/endpoint/security/KeyUtil.java +++ b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/endpoint/security/KeyUtil.java @@ -64,7 +64,8 @@ private KeyUtil() { * @param publicKeyFile the public key file * @throws IOException Signals that an I/O exception has occurred. */ - public static void saveKeyPair(KeyPair keyPair, String privateKeyFile, String publicKeyFile) throws IOException { + public static void saveKeyPair(KeyPair keyPair, String privateKeyFile, + String publicKeyFile) throws IOException { File privateFile = makeDirs(privateKeyFile); File publicFile = makeDirs(publicKeyFile); OutputStream privateKeyOutput = null; @@ -87,7 +88,8 @@ public static void saveKeyPair(KeyPair keyPair, String privateKeyFile, String pu * @param publicKeyOutput the public key output stream * @throws IOException Signals that an I/O exception has occurred. */ - public static void saveKeyPair(KeyPair keyPair, OutputStream privateKeyOutput, OutputStream publicKeyOutput) throws IOException { + public static void saveKeyPair(KeyPair keyPair, OutputStream privateKeyOutput, + OutputStream publicKeyOutput) throws IOException { PrivateKey privateKey = keyPair.getPrivate(); PublicKey publicKey = keyPair.getPublic(); @@ -110,8 +112,11 @@ public static void saveKeyPair(KeyPair keyPair, OutputStream privateKeyOutput, O */ private static File makeDirs(String privateKeyFile) { File privateFile = new File(privateKeyFile); - if (privateFile.getParentFile() != null && !privateFile.getParentFile().exists() && !privateFile.getParentFile().mkdirs()) { - LOG.warn("Failed to create required directories: {}", privateFile.getParentFile().getAbsolutePath()); + if (privateFile.getParentFile() != null + && !privateFile.getParentFile().exists() + && !privateFile.getParentFile().mkdirs()) { + LOG.warn("Failed to create required directories: {}", + privateFile.getParentFile().getAbsolutePath()); } return privateFile; } @@ -128,8 +133,8 @@ public static KeyPair generateKeyPair(String privateKeyLocation, String publicKe KeyPair clientKeyPair = generateKeyPair(); saveKeyPair(clientKeyPair, privateKeyLocation, publicKeyLocation); return clientKeyPair; - } catch (Exception e) { - LOG.error("Error generating client key pair", e); + } catch (Exception ex) { + LOG.error("Error generating client key pair", ex); } return null; } @@ -141,13 +146,14 @@ public static KeyPair generateKeyPair(String privateKeyLocation, String publicKe * @param publicKeyOutput the public key output stream * @return the key pair */ - public static KeyPair generateKeyPair(OutputStream privateKeyOutput, OutputStream publicKeyOutput) { + public static KeyPair generateKeyPair(OutputStream privateKeyOutput, + OutputStream publicKeyOutput) { try { KeyPair clientKeyPair = generateKeyPair(); saveKeyPair(clientKeyPair, privateKeyOutput, publicKeyOutput); return clientKeyPair; - } catch (Exception e) { - LOG.error("Error generating client key pair", e); + } catch (Exception ex) { + LOG.error("Error generating client key pair", ex); } return null; } @@ -161,17 +167,13 @@ public static KeyPair generateKeyPair() throws NoSuchAlgorithmException { /** * Gets the public key from file. * - * @param f the f - * @return the public - * @throws IOException the i/o exception - * @throws InvalidKeyException invalid key exception */ - public static PublicKey getPublic(File f) throws IOException, InvalidKeyException { + public static PublicKey getPublic(File file) throws IOException, InvalidKeyException { DataInputStream dis = null; try { - FileInputStream fis = new FileInputStream(f); + FileInputStream fis = new FileInputStream(file); dis = new DataInputStream(fis); - byte[] keyBytes = new byte[(int) f.length()]; + byte[] keyBytes = new byte[(int) file.length()]; dis.readFully(keyBytes); return getPublic(keyBytes); } finally { @@ -211,25 +213,25 @@ public static PublicKey getPublic(byte[] keyBytes) throws InvalidKeyException { X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); KeyFactory kf = KeyFactory.getInstance(RSA); return kf.generatePublic(spec); - } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { - throw new InvalidKeyException(e); + } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) { + throw new InvalidKeyException(ex); } } /** * Gets the private key from file. * - * @param f the f + * @param file the file * @return the private * @throws IOException the i/o exception * @throws InvalidKeyException invalid key exception */ - public static PrivateKey getPrivate(File f) throws IOException, InvalidKeyException { + public static PrivateKey getPrivate(File file) throws IOException, InvalidKeyException { DataInputStream dis = null; try { - FileInputStream fis = new FileInputStream(f); + FileInputStream fis = new FileInputStream(file); dis = new DataInputStream(fis); - byte[] keyBytes = new byte[(int) f.length()]; + byte[] keyBytes = new byte[(int) file.length()]; dis.readFully(keyBytes); return getPrivate(keyBytes); } finally { @@ -269,8 +271,8 @@ public static PrivateKey getPrivate(byte[] keyBytes) throws InvalidKeyException PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); KeyFactory kf = KeyFactory.getInstance(RSA); return kf.generatePrivate(spec); - } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { - throw new InvalidKeyException(e); + } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) { + throw new InvalidKeyException(ex); } } @@ -298,8 +300,8 @@ public static boolean validateKeyPair(KeyPair keyPair) { try { encodedPayload = encDec.encodeData(rawPayload); decodedPayload = encDec.decodeData(encodedPayload); - } catch (GeneralSecurityException e) { - LOG.error("Validation keypair error ", e); + } catch (GeneralSecurityException ex) { + LOG.error("Validation keypair error ", ex); return false; } return Arrays.equals(rawPayload, decodedPayload); diff --git a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/endpoint/security/MessageEncoderDecoder.java b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/endpoint/security/MessageEncoderDecoder.java index d627864abd..0b5c017fec 100644 --- a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/endpoint/security/MessageEncoderDecoder.java +++ b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/endpoint/security/MessageEncoderDecoder.java @@ -106,8 +106,8 @@ public MessageEncoderDecoder(PrivateKey privateKey, PublicKey publicKey, PublicK static Cipher cipherForAlgorithm(String algorithm) { try { return Cipher.getInstance(algorithm); - } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { - LOG.error("Cipher init error", e); + } catch (NoSuchAlgorithmException | NoSuchPaddingException ex) { + LOG.error("Cipher init error", ex); return null; } } @@ -117,8 +117,8 @@ static KeyGenerator keyGeneratorForAlgorithm(String algorithm, int size) { KeyGenerator keyGen = KeyGenerator.getInstance(algorithm); keyGen.init(size); return keyGen; - } catch (NoSuchAlgorithmException e) { - LOG.error("Key generator init error", e); + } catch (NoSuchAlgorithmException ex) { + LOG.error("Key generator init error", ex); return null; } } @@ -126,8 +126,8 @@ static KeyGenerator keyGeneratorForAlgorithm(String algorithm, int size) { static Signature signatureForAlgorithm(String algorithm) { try { return Signature.getInstance(algorithm); - } catch (NoSuchAlgorithmException e) { - LOG.error("Signature init error", e); + } catch (NoSuchAlgorithmException ex) { + LOG.error("Signature init error", ex); return null; } } diff --git a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/hash/SHA1HashUtils.java b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/hash/SHA1HashUtils.java index 1662bacfc4..a3cc8d43e5 100644 --- a/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/hash/SHA1HashUtils.java +++ b/common/endpoint-shared/src/main/java/org/kaaproject/kaa/common/hash/SHA1HashUtils.java @@ -46,8 +46,8 @@ private SHA1HashUtils() { static MessageDigest forAlgorithm(String algorithm) { try { return MessageDigest.getInstance(algorithm); - } catch (NoSuchAlgorithmException e) { - LOG.error("No such algorithm: {}, exception catched: {}", algorithm, e); + } catch (NoSuchAlgorithmException ex) { + LOG.error("No such algorithm: {}, exception catched: {}", algorithm, ex); return null; } } diff --git a/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/HttpComponentsRequestFactoryBasicAuth.java b/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/HttpComponentsRequestFactoryBasicAuth.java index d303632880..d75e3e86de 100644 --- a/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/HttpComponentsRequestFactoryBasicAuth.java +++ b/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/HttpComponentsRequestFactoryBasicAuth.java @@ -111,7 +111,7 @@ public boolean retryRequest(IOException exception, int executionCount, try { LOG.warn("IOException '{}'. Wait for {} before next attempt to connect...", exception.getMessage(), connectRetryInterval); Thread.sleep(connectRetryInterval); - } catch (InterruptedException e) { + } catch (InterruptedException ex) { } return true; } else { diff --git a/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/KaaRestTemplate.java b/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/KaaRestTemplate.java index 043973c476..9f047bcaca 100644 --- a/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/KaaRestTemplate.java +++ b/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/KaaRestTemplate.java @@ -121,15 +121,15 @@ protected T doExecute(URI url, HttpMethod method, RequestCallback requestCal } try { setNewRequestFactory(index); - } catch (Exception e) { - logger.info("Failed to initialize new request factory ({}:{})", getCurHost(), getCurPort(), e); + } catch (Exception exp) { + logger.info("Failed to initialize new request factory ({}:{})", getCurHost(), getCurPort(), exp); continue; } url = updateURL(url); isRequestFactorySet = true; } - } catch (RestClientException e) { - throw e; + } catch (RestClientException exp) { + throw exp; } } } diff --git a/server/common/admin-rest-client/src/test/java/org/kaaproject/kaa/server/common/admin/TestMessage.java b/server/common/admin-rest-client/src/test/java/org/kaaproject/kaa/server/common/admin/TestMessage.java index fbb21f21e4..0eed208eb9 100644 --- a/server/common/admin-rest-client/src/test/java/org/kaaproject/kaa/server/common/admin/TestMessage.java +++ b/server/common/admin-rest-client/src/test/java/org/kaaproject/kaa/server/common/admin/TestMessage.java @@ -51,10 +51,10 @@ public String getMessage(KaaRestTemplate kaaRestTemplate, TestHttpMethods httpMe } } - } catch (HttpStatusCodeException e) { - result = "Get FAILED with HttpStatusCode: " + e.getStatusCode() + "|" + e.getStatusText(); - } catch (RuntimeException e) { - result = "Get FAILED\n" + ExceptionUtils.getFullStackTrace(e); + } catch (HttpStatusCodeException ex) { + result = "Get FAILED with HttpStatusCode: " + ex.getStatusCode() + "|" + ex.getStatusText(); + } catch (RuntimeException ex) { + result = "Get FAILED\n" + ExceptionUtils.getFullStackTrace(ex); } return result; } diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/DaoUtil.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/DaoUtil.java index 37a44816e9..42784e24b4 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/DaoUtil.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/DaoUtil.java @@ -160,8 +160,8 @@ public static String getStringFromFile(String name, Class clazz) { if (arrayData != null) { data = new String(arrayData, Charset.forName("UTF-8")); } - } catch (IOException e) { - LOG.error("Can't read data from file", e); + } catch (IOException ex) { + LOG.error("Can't read data from file", ex); } } } diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/sql/HibernateAbstractDao.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/sql/HibernateAbstractDao.java index 9135a0521b..e6169f87b3 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/sql/HibernateAbstractDao.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/impl/sql/HibernateAbstractDao.java @@ -96,7 +96,7 @@ protected List toLongIds(List ids) { try { Long lid = Long.parseLong(id); lids.add(lid); - } catch (NumberFormatException e) { + } catch (NumberFormatException ex) { LOG.warn("Can't convert string id {} to Long id", id); } } diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/model/sql/ModelUtils.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/model/sql/ModelUtils.java index 4e5d652a62..3d502adf1c 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/model/sql/ModelUtils.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/model/sql/ModelUtils.java @@ -73,7 +73,7 @@ public static Long getLongId(String id) { if (isNotBlank(id)) { try { longId = Long.valueOf(id); - } catch (NumberFormatException e) { + } catch (NumberFormatException ex) { LOG.error("Can't convert to Long id. Incorrect String id {} ", id); } } @@ -175,8 +175,8 @@ public static String binaryToString(byte[] data) { if (data != null) { try { body = new String(data, UTF8); - } catch (UnsupportedEncodingException e) { - LOG.warn("Can't convert binary data to string. ", e); + } catch (UnsupportedEncodingException ex) { + LOG.warn("Can't convert binary data to string. ", ex); } } return body; @@ -187,8 +187,8 @@ public static byte[] stringToBinary(String body) { if (body != null) { try { data = body.getBytes(UTF8); - } catch (UnsupportedEncodingException e) { - LOG.warn("Can't convert string data to binary. ", e); + } catch (UnsupportedEncodingException ex) { + LOG.warn("Can't convert string data to binary. ", ex); } } return data; @@ -306,8 +306,8 @@ public static String getStringFromFile(String name, Class clazz) { if (arrayData != null) { data = new String(arrayData, Charset.forName("UTF-8")); } - } catch (IOException e) { - LOG.error("Can't read data from file", e); + } catch (IOException ex) { + LOG.error("Can't read data from file", ex); } } } diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/schema/EventSchemaProcessorImpl.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/schema/EventSchemaProcessorImpl.java index 10b3132cdc..74c47d8fa0 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/schema/EventSchemaProcessorImpl.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/schema/EventSchemaProcessorImpl.java @@ -57,8 +57,8 @@ public List processSchema(String schema) EventClassType classType = null; try { //NOSONAR classType = EventClassType.valueOf(strClassType.toUpperCase()); - } catch (Exception e) { - LOG.error("Can't process provided event class family schema. Invalid classType [{}]. Exception catched: {}", strClassType, e); + } catch (Exception ex) { + LOG.error("Can't process provided event class family schema. Invalid classType [{}]. Exception catched: {}", strClassType, ex); throw new EventSchemaException("Can't process provided event class family schema. Invalid classType: " + strClassType); } String ctlSchemaId = parsedEventClassSchema.getProp(CTL_SCHEMA_ID); @@ -66,9 +66,9 @@ public List processSchema(String schema) eventClassSchema.setType(classType); eventClassSchemas.add(eventClassSchema); } - } catch (Exception e) { - LOG.error("Invalid event class family schema.", e); - throw new EventSchemaException("Can't process provided event class family schema.", e); + } catch (Exception ex) { + LOG.error("Invalid event class family schema.", ex); + throw new EventSchemaException("Can't process provided event class family schema.", ex); } return eventClassSchemas; } diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CTLServiceImpl.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CTLServiceImpl.java index 5562df4b29..1687431133 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CTLServiceImpl.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/CTLServiceImpl.java @@ -171,9 +171,9 @@ private void validateDefaultRecord(CTLSchemaDto unSavedSchema) { String schemaBody = flatExportAsString(unSavedSchema); GenericAvroConverter converter = new GenericAvroConverter(schemaBody); converter.decodeJson(unSavedSchema.getDefaultRecord()); - } catch (IOException | RuntimeException e) { - LOG.error("Invalid default record for CTL schema with body: {}", unSavedSchema.getBody(), e); - throw new RuntimeException("An unexpected exception occured: " + e.toString()); + } catch (IOException | RuntimeException ex) { + LOG.error("Invalid default record for CTL schema with body: {}", unSavedSchema.getBody(), ex); + throw new RuntimeException("An unexpected exception occured: " + ex.toString()); } } @@ -186,13 +186,13 @@ private CTLSchemaDto generateDefaultRecord(CTLSchemaDto unSavedSchema) { dataSchema, new RawDataFactory()); unSavedSchema.setDefaultRecord(dataProcessor.getRootData().getRawData()); return unSavedSchema; - } catch (StackOverflowError e) { - LOG.error("Failed to generate default record. An endless recursion is detected. CTL schema body: {}", unSavedSchema.getBody(), e); + } catch (StackOverflowError ex) { + LOG.error("Failed to generate default record. An endless recursion is detected. CTL schema body: {}", unSavedSchema.getBody(), ex); throw new RuntimeException("Unable to generate default record. An endless recursion is detected! " + "Please check non-optional references to nested types."); - } catch (ConfigurationGenerationException | IOException | RuntimeException e) { - LOG.error("Failed to generate default record for CTL schema with body: {}", unSavedSchema.getBody(), e); - throw new RuntimeException("An unexpected exception occured: " + e.toString()); + } catch (ConfigurationGenerationException | IOException | RuntimeException ex) { + LOG.error("Failed to generate default record for CTL schema with body: {}", unSavedSchema.getBody(), ex); + throw new RuntimeException("An unexpected exception occured: " + ex.toString()); } } diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/SdkTokenGenerator.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/SdkTokenGenerator.java index 5c00d3241e..2fca414dc8 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/SdkTokenGenerator.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/SdkTokenGenerator.java @@ -37,8 +37,8 @@ public static void generateSdkToken(SdkProfileDto sdkProfileDto) { MessageDigest messageDigest = MessageDigest.getInstance(SDK_TOKEN_HASH_ALGORITHM); messageDigest.update(DtoByteMarshaller.toBytes(sdkProfileDto.toSdkTokenDto())); sdkProfileDto.setToken(Base64.encodeBase64URLSafeString(messageDigest.digest())); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); + } catch (NoSuchAlgorithmException ex) { + throw new RuntimeException(ex); } } } diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/UserConfigurationServiceImpl.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/UserConfigurationServiceImpl.java index 9f09675efb..9fcf24e6db 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/UserConfigurationServiceImpl.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/UserConfigurationServiceImpl.java @@ -89,8 +89,8 @@ public EndpointUserConfigurationDto saveUserConfiguration(EndpointUserConfigurat LOG.warn("Validated endpoint user configuration body is empty"); throw new IncorrectParameterException("Validated endpoint user configuration body is empty"); } - } catch (IOException e) { - LOG.error("Invalid endpoint user configuration for override schema.", e); + } catch (IOException ex) { + LOG.error("Invalid endpoint user configuration for override schema.", ex); throw new IncorrectParameterException("Invalid endpoint user configuration for override schema."); } } else { diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/Validator.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/Validator.java index 062f6a2fa4..a5aab22e01 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/Validator.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/Validator.java @@ -131,8 +131,8 @@ public static void validateId(String id, String errorMessage) { public static void validateSqlId(String id, String errorMessage) { try { Long.valueOf(id); - } catch (NumberFormatException e) { - throw new IncorrectParameterException(errorMessage, e); + } catch (NumberFormatException ex) { + throw new IncorrectParameterException(errorMessage, ex); } } diff --git a/server/common/dao/src/test/java/org/kaaproject/kaa/server/common/dao/AbstractTest.java b/server/common/dao/src/test/java/org/kaaproject/kaa/server/common/dao/AbstractTest.java index f8e03c057f..d8efc592f4 100644 --- a/server/common/dao/src/test/java/org/kaaproject/kaa/server/common/dao/AbstractTest.java +++ b/server/common/dao/src/test/java/org/kaaproject/kaa/server/common/dao/AbstractTest.java @@ -262,7 +262,7 @@ protected String readSchemaFileAsString(String filePath) throws IOException { FileSystem fs; try { fs = FileSystems.newFileSystem(URI.create(array[0]), new HashMap()); - } catch (FileSystemAlreadyExistsException e) { + } catch (FileSystemAlreadyExistsException ex) { fs = FileSystems.getFileSystem(URI.create(array[0])); } path = fs.getPath(array[1]); @@ -270,8 +270,8 @@ protected String readSchemaFileAsString(String filePath) throws IOException { path = Paths.get(uri); } return new String(Files.readAllBytes(path)); - } catch (URISyntaxException e) { - LOG.error("Can't generate configs {}", e); + } catch (URISyntaxException ex) { + LOG.error("Can't generate configs {}", ex); } return null; } @@ -339,9 +339,9 @@ protected List generateConfSchemaDto(String tenantId, St schemas.add(schemaDto); } - } catch (Exception e) { - LOG.error("Can't generate configs {}", e); - Assert.fail("Can't generate configuration schemas." + e.getMessage()); + } catch (Exception ex) { + LOG.error("Can't generate configs {}", ex); + Assert.fail("Can't generate configuration schemas." + ex.getMessage()); } return schemas; } @@ -382,9 +382,9 @@ protected List generateConfigurationDto(String schemaId, Strin } ids.add(saved); } - } catch (Exception e) { - LOG.error("Can't generate configs {}", e); - Assert.fail("Can't generate configurations. " + e.getMessage()); + } catch (Exception ex) { + LOG.error("Can't generate configs {}", ex); + Assert.fail("Can't generate configurations. " + ex.getMessage()); } return ids; } @@ -411,8 +411,8 @@ protected List generateProfSchemaDto(String tenantId, Assert.assertNotNull(schemaDto); schemas.add(schemaDto); } - } catch (Exception e) { - LOG.error("Can't generate configs {}", e); + } catch (Exception ex) { + LOG.error("Can't generate configs {}", ex); Assert.fail("Can't generate configurations."); } return schemas; @@ -459,8 +459,8 @@ protected List generateFilterDto(String schemaId, String serve } filters.add(saved); } - } catch (Exception e) { - LOG.error("Can't generate configs {}", e); + } catch (Exception ex) { + LOG.error("Can't generate configs {}", ex); Assert.fail("Can't generate configurations."); } return filters; @@ -494,7 +494,7 @@ protected List generateLogSchemaDto(String appId, int count) { CTLSchemaDto ctlSchema = null; try { ctlSchema = ctlService.saveCTLSchema(generateCTLSchemaDto(app.getTenantId())); - } catch (DatabaseProcessingException e) { + } catch (DatabaseProcessingException ex) { ctlSchema = ctlService.getOrCreateEmptySystemSchema(USER_NAME); } @@ -505,8 +505,8 @@ protected List generateLogSchemaDto(String appId, int count) { Assert.assertNotNull(schemaDto); schemas.add(schemaDto); } - } catch (Exception e) { - LOG.error("Can't generate log schemas {}", e); + } catch (Exception ex) { + LOG.error("Can't generate log schemas {}", ex); Assert.fail("Can't generate log schemas."); } return schemas; @@ -589,7 +589,7 @@ protected NotificationSchemaDto generateNotificationSchemaDto(String appId, Noti CTLSchemaDto ctlSchema = null; try { ctlSchema = ctlService.saveCTLSchema(generateCTLSchemaDto(app.getTenantId())); - } catch (DatabaseProcessingException e) { + } catch (DatabaseProcessingException ex) { ctlSchema = ctlService.getOrCreateEmptySystemSchema(USER_NAME); } @@ -618,9 +618,9 @@ protected List generateNotificationsDto(String schemaId, String byte[] body = null; try { body = readSchemaFileAsString("dao/schema/testBaseData.json").getBytes(Charset.forName("UTF-8")); - } catch (IOException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); + } catch (IOException ex) { + ex.printStackTrace(); + Assert.fail(ex.getMessage()); } notification.setBody(body); UpdateNotificationDto update = notificationService.saveNotification(notification); @@ -649,9 +649,9 @@ protected EndpointNotificationDto generateUnicastNotificationDto(String schemaId byte[] body = null; try { body = readSchemaFileAsString("dao/schema/testBaseData.json").getBytes(Charset.forName("UTF-8")); - } catch (IOException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); + } catch (IOException ex) { + ex.printStackTrace(); + Assert.fail(ex.getMessage()); } notification.setBody(body); endpointNotification.setNotificationDto(notification); @@ -742,8 +742,8 @@ protected EndpointProfileDto generateEndpointProfileDto(String appId, List generateConfSchema(Application app, int coun Assert.assertNotNull(schema); schemas.add(schema); } - } catch (Exception e) { - LOG.error("Can't generate configuration schemas {}", e); - Assert.fail("Can't generate configuration schemas." + e.getMessage()); + } catch (Exception ex) { + LOG.error("Can't generate configuration schemas {}", ex); + Assert.fail("Can't generate configuration schemas." + ex.getMessage()); } return schemas; } @@ -206,9 +206,9 @@ protected List generateConfiguration(ConfigurationSchema schema, Assert.assertNotNull(saved); configs.add(saved); } - } catch (Exception e) { - LOG.error("Can't generate configs {}", e); - Assert.fail("Can't generate configurations." + e.getMessage()); + } catch (Exception ex) { + LOG.error("Can't generate configs {}", ex); + Assert.fail("Can't generate configurations." + ex.getMessage()); } return configs; } @@ -282,9 +282,9 @@ protected List generateNotificationSchema(Application app, i Assert.assertNotNull(schemaDto); schemas.add(schemaDto); } - } catch (Exception e) { - LOG.error("Can't generate profile schema {}", e); - Assert.fail("Can't generate profile schema." + e.getMessage()); + } catch (Exception ex) { + LOG.error("Can't generate profile schema {}", ex); + Assert.fail("Can't generate profile schema." + ex.getMessage()); } return schemas; } @@ -500,8 +500,8 @@ protected List generateLogSchema(Tenant tenant, int ctlVersion, Appli Assert.assertNotNull(schema); schemas.add(schema); } - } catch (Exception e) { - LOG.error("Can't generate log schemas {}", e); + } catch (Exception ex) { + LOG.error("Can't generate log schemas {}", ex); Assert.fail("Can't generate log schemas."); } return schemas; diff --git a/server/common/thrift-cli-client/src/main/java/org/kaaproject/kaa/server/common/thrift/cli/client/BaseCliThriftClient.java b/server/common/thrift-cli-client/src/main/java/org/kaaproject/kaa/server/common/thrift/cli/client/BaseCliThriftClient.java index a884c6cf59..9098d377eb 100644 --- a/server/common/thrift-cli-client/src/main/java/org/kaaproject/kaa/server/common/thrift/cli/client/BaseCliThriftClient.java +++ b/server/common/thrift-cli-client/src/main/java/org/kaaproject/kaa/server/common/thrift/cli/client/BaseCliThriftClient.java @@ -74,8 +74,8 @@ public static void main(String[] args) throws Exception { //NOSONAR try { ss.out = new PrintStream(System.out, true, "UTF-8"); //NOSONAR ss.err = new PrintStream(System.err, true, "UTF-8"); //NOSONAR - } catch (UnsupportedEncodingException e) { - LOG.error("Exception catched: ", e); + } catch (UnsupportedEncodingException ex) { + LOG.error("Exception catched: ", ex); System.exit(3); //NOSONAR } @@ -168,11 +168,11 @@ public int processCmd(String cmd) { } err.println("[Thrift CLI Error]: " + errMsg); } - } catch (TException e) { - LOG.error("Exception catched: ", e); - String errMsg = e.getMessage(); + } catch (TException ex) { + LOG.error("Exception catched: ", ex); + String errMsg = ex.getMessage(); if (errMsg == null) { - errMsg = e.toString(); + errMsg = ex.toString(); } ret = -10002; err.println("[Thrift Error]: " + errMsg); @@ -197,8 +197,8 @@ public int processCmd(String cmd) { int port = 0; try { port = Integer.valueOf(strPort); - } catch (Exception e) { - LOG.error("Unexpected exception while parsing port. Can not parse String: {} to Integer, exception catched {}", strPort, e); + } catch (Exception ex) { + LOG.error("Unexpected exception while parsing port. Can not parse String: {} to Integer, exception catched {}", strPort, ex); } if (port > 0) { parsed = true; @@ -206,10 +206,10 @@ public int processCmd(String cmd) { ss.port = port; try { ss.connect(); - } catch (TException e) { - String errMsg = e.getMessage(); + } catch (TException ex) { + String errMsg = ex.getMessage(); if (errMsg == null) { - errMsg = e.toString(); + errMsg = ex.toString(); } err.println("[Thrift Error]: " + errMsg); } diff --git a/server/common/thrift-cli-server/src/main/java/org/kaaproject/kaa/server/common/thrift/cli/server/BaseCliThriftService.java b/server/common/thrift-cli-server/src/main/java/org/kaaproject/kaa/server/common/thrift/cli/server/BaseCliThriftService.java index b519a7e5f5..7133b678b4 100644 --- a/server/common/thrift-cli-server/src/main/java/org/kaaproject/kaa/server/common/thrift/cli/server/BaseCliThriftService.java +++ b/server/common/thrift-cli-server/src/main/java/org/kaaproject/kaa/server/common/thrift/cli/server/BaseCliThriftService.java @@ -172,8 +172,8 @@ public void run() { try { ThriftExecutor.shutdown(); System.exit(0); //NOSONAR - } catch (Exception e) { - LOG.error("Catch exception when execute shutdown command", e); + } catch (Exception ex) { + LOG.error("Catch exception when execute shutdown command", ex); } } }; @@ -230,7 +230,7 @@ public CommandResult executeCommand(String commandLineString) } else { command.runCommand(commandLine, writer); } - } catch (ParseException e) { + } catch (ParseException ex) { writer.println("Unable to parse command arguments."); writer.println(); printHelp(command, writer); @@ -300,8 +300,8 @@ private void printMemory(PrintWriter writer, boolean forceGC) { writer.println("Used : " + format.format((float) (memUsage.total - memUsage.free) / (float) MBYTE) + " MBytes"); - } catch (TException e) { - LOG.error("Catch exception when execute print memory command", e); + } catch (TException ex) { + LOG.error("Catch exception when execute print memory command", ex); } } @@ -485,8 +485,8 @@ private void shutdown(PrintWriter writer) { writer.println("Server shutdown initiated."); try { shutdown(); - } catch (TException e) { - LOG.error("Catch exception when execute shutdown command", e); + } catch (TException ex) { + LOG.error("Catch exception when execute shutdown command", ex); } } @@ -510,14 +510,14 @@ protected String createPadding(int len) { * Creates the padding using specified character. * * @param len length of the padding - * @param c the character to use for padding + * @param character the character to use for padding * @return the resulting padding string */ - protected String createPadding(int len, char c) { + protected String createPadding(int len, char character) { StringBuffer sb = new StringBuffer(len); for (int i = 0; i < len; ++i) { - sb.append(c); + sb.append(character); } return sb.toString(); diff --git a/server/common/thrift/src/main/java/org/kaaproject/kaa/server/common/thrift/util/ThriftClient.java b/server/common/thrift/src/main/java/org/kaaproject/kaa/server/common/thrift/util/ThriftClient.java index 82ce3c4cbb..d71a80327a 100644 --- a/server/common/thrift/src/main/java/org/kaaproject/kaa/server/common/thrift/util/ThriftClient.java +++ b/server/common/thrift/src/main/java/org/kaaproject/kaa/server/common/thrift/util/ThriftClient.java @@ -145,10 +145,10 @@ public void run() { } } catch (TException | IllegalArgumentException - | SecurityException e) { + | SecurityException ex) { LOG.error( "Unexpected error occurred while invoke thrift object " + endpointHost + ":" + endpointPort, - e); + ex); if (activity != null) { activity.isSuccess(false); } diff --git a/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/ControlNodeTracker.java b/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/ControlNodeTracker.java index fd28f21e33..61f53b8655 100644 --- a/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/ControlNodeTracker.java +++ b/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/ControlNodeTracker.java @@ -108,8 +108,8 @@ protected AvroByteArrayConverter initialValue() { */ private final UnhandledErrorListener errorsListener = new UnhandledErrorListener() { @Override - public void unhandledError(String message, Throwable e) { - LOG.error("Unrecoverable error: " + message, e); + public void unhandledError(String message, Throwable ex) { + LOG.error("Unrecoverable error: " + message, ex); try { close(); } catch (IOException ioe) { @@ -234,8 +234,8 @@ public void close() throws IOException { try { zkClient.delete().forPath(nodePath); LOG.debug("Node with path {} successfully deleted", nodePath); - } catch (Exception e) { - LOG.debug("Failed to delete node", e); + } catch (Exception ex) { + LOG.debug("Failed to delete node", ex); } } } @@ -266,8 +266,8 @@ private ControlNodeInfo extractControlServerInfo(ChildData currentData) { ControlNodeInfo controlServerInfo = null; try { controlServerInfo = controlNodeAvroConverter.get().fromByteArray(currentData.getData(), controlServerInfo); - } catch (IOException e) { - LOG.error("error reading control service info", e); + } catch (IOException ex) { + LOG.error("error reading control service info", ex); } return controlServerInfo; } @@ -280,11 +280,11 @@ public boolean doZKClientAction(ZKClientAction action, boolean throwIOException) try { action.doWithZkClient(zkClient); return true; - } catch (Exception e) { - LOG.error("Unknown Error", e); + } catch (Exception ex) { + LOG.error("Unknown Error", ex); close(); if (throwIOException) { - throw new IOException(e); + throw new IOException(ex); } else { return false; } diff --git a/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/WorkerNodeTracker.java b/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/WorkerNodeTracker.java index b498461784..b879e04547 100644 --- a/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/WorkerNodeTracker.java +++ b/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/WorkerNodeTracker.java @@ -351,9 +351,10 @@ public boolean removeListener(BootstrapNodeListener listener) { private OperationsNodeInfo extractOperationServerInfo(ChildData currentData) { OperationsNodeInfo endpointServerInfo = null; try { - endpointServerInfo = operationsNodeAvroConverter.get().fromByteArray(currentData.getData(), null); - } catch (IOException e) { - LOG.error("error reading control service info", e); + endpointServerInfo = operationsNodeAvroConverter.get().fromByteArray( + currentData.getData(), null); + } catch (IOException ex) { + LOG.error("error reading control service info", ex); } return endpointServerInfo; } @@ -367,21 +368,22 @@ private OperationsNodeInfo extractOperationServerInfo(ChildData currentData) { private BootstrapNodeInfo extractBootstrapServerInfo(ChildData currentData) { BootstrapNodeInfo bootstrapServerInfo = null; try { - bootstrapServerInfo = bootstrapNodeAvroConverter.get().fromByteArray(currentData.getData(), null); - } catch (IOException e) { - LOG.error("error reading control service info", e); + bootstrapServerInfo = bootstrapNodeAvroConverter.get().fromByteArray( + currentData.getData(), null); + } catch (IOException ex) { + LOG.error("error reading control service info", ex); } return bootstrapServerInfo; } private String constructEndpointAddress(OperationsNodeInfo nodeInfo) { - return nodeInfo.getConnectionInfo().getThriftHost() + ":" + - String.valueOf(nodeInfo.getConnectionInfo().getThriftPort()); + return nodeInfo.getConnectionInfo().getThriftHost() + ":" + + String.valueOf(nodeInfo.getConnectionInfo().getThriftPort()); } private String constructBootstrapAddress(BootstrapNodeInfo nodeInfo) { - return nodeInfo.getConnectionInfo().getThriftHost() + ":" + - String.valueOf(nodeInfo.getConnectionInfo().getThriftPort()); + return nodeInfo.getConnectionInfo().getThriftHost() + ":" + + String.valueOf(nodeInfo.getConnectionInfo().getThriftPort()); } /* diff --git a/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/control/ControlNode.java b/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/control/ControlNode.java index bf3c19e17a..699a75ee4f 100644 --- a/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/control/ControlNode.java +++ b/server/common/zk/src/main/java/org/kaaproject/kaa/server/common/zk/control/ControlNode.java @@ -118,12 +118,12 @@ public boolean createZkNode() throws IOException { nodePath = zkClient.create().withMode(CreateMode.EPHEMERAL) .forPath(ControlNodeTracker.CONTROL_SERVER_NODE_PATH, controlNodeAvroConverter.get().toByteArray(currentNodeInfo)); LOG.info("Created node with path: " + nodePath); - } catch (NodeExistsException e) { - LOG.info("master already exists ", e); - } catch (Exception e) { - LOG.error("Unknown Error", e); + } catch (NodeExistsException ex) { + LOG.info("master already exists ", ex); + } catch (Exception ex) { + LOG.error("Unknown Error", ex); close(); - throw new IOException(e); + throw new IOException(ex); } return true; } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/ConfigurationServiceImpl.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/ConfigurationServiceImpl.java index f97a056eaa..560ecc516c 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/ConfigurationServiceImpl.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/ConfigurationServiceImpl.java @@ -84,8 +84,8 @@ public List getConfigurationSchemasByApplicationId(Strin try { checkApplicationId(applicationId); return controlService.getConfigurationSchemasByApplicationId(applicationId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -95,8 +95,8 @@ public List getVacantConfigurationSchemasByEndpointGroupId(String en try { checkEndpointGroupId(endpointGroupId); return controlService.getVacantConfigurationSchemasByEndpointGroupId(endpointGroupId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -108,8 +108,8 @@ public ConfigurationSchemaDto getConfigurationSchema(String configurationSchemaI Utils.checkNotNull(configurationSchema); checkApplicationId(configurationSchema.getApplicationId()); return configurationSchema; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -126,8 +126,8 @@ public ConfigurationSchemaDto saveConfigurationSchema(ConfigurationSchemaDto con checkApplicationId(storedConfSchema.getApplicationId()); } return controlService.editConfigurationSchema(confSchema); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -156,8 +156,8 @@ public ConfigurationSchemaViewDto saveConfigurationSchemaView(ConfigurationSchem ConfigurationSchemaDto savedConfSchema = saveConfigurationSchema(confSchema); return getConfigurationSchemaView(savedConfSchema.getId()); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -168,8 +168,8 @@ public ConfigurationSchemaViewDto getConfigurationSchemaView(String configuratio ConfigurationSchemaDto confSchema = getConfigurationSchema(configurationSchemaId); CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(confSchema.getCtlSchemaId()); return new ConfigurationSchemaViewDto(confSchema, toCtlSchemaForm(ctlSchemaDto, ConverterType.CONFIGURATION_FORM_AVRO_CONVERTER)); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -180,8 +180,8 @@ public List getConfigurationRecordsByEndpointGroupId(Str try { checkEndpointGroupId(endpointGroupId); return controlService.getConfigurationRecordsByEndpointGroupId(endpointGroupId, includeDeprecated); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -193,8 +193,8 @@ public ConfigurationRecordDto getConfigurationRecord(String schemaId, String end checkEndpointGroupId(endpointGroupId); ConfigurationRecordDto record = controlService.getConfigurationRecord(schemaId, endpointGroupId); return record; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -213,12 +213,12 @@ public ConfigurationDto editConfiguration(ConfigurationDto configuration) throws checkEndpointGroupId(storedConfiguration.getEndpointGroupId()); } return controlService.editConfiguration(configuration); - } catch (StaleObjectStateException e) { - LOG.error("Someone has already updated the configuration. Reload page to be able to edit it. ", e); + } catch (StaleObjectStateException ex) { + LOG.error("Someone has already updated the configuration. Reload page to be able to edit it. ", ex); throw new KaaAdminServiceException("Someone has already updated the configuration. Reload page to be able to edit it.", ServiceErrorCode.GENERAL_ERROR); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -228,8 +228,8 @@ public void editUserConfiguration(EndpointUserConfigurationDto endpointUserConfi try { checkApplicationToken(endpointUserConfiguration.getAppToken()); controlService.editUserConfiguration(endpointUserConfiguration); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -242,8 +242,8 @@ public ConfigurationDto activateConfiguration(String configurationId) throws Kaa checkEndpointGroupId(storedConfiguration.getEndpointGroupId()); String username = getCurrentUser().getUsername(); return controlService.activateConfiguration(configurationId, username); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -256,8 +256,8 @@ public ConfigurationDto deactivateConfiguration(String configurationId) throws K checkEndpointGroupId(storedConfiguration.getEndpointGroupId()); String username = getCurrentUser().getUsername(); return controlService.deactivateConfiguration(configurationId, username); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -269,8 +269,8 @@ public void deleteConfigurationRecord(String schemaId, String endpointGroupId) t checkEndpointGroupId(record.getEndpointGroupId()); String username = getCurrentUser().getUsername(); controlService.deleteConfigurationRecord(schemaId, endpointGroupId, username); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -282,8 +282,8 @@ public RecordField generateConfigurationSchemaForm(String fileItemName) throws K Schema schema = new Schema.Parser().parse(avroSchema); validateRecordSchema(schema); return configurationSchemaFormAvroConverter.createSchemaFormFromSchema(schema); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -295,8 +295,8 @@ public ConfigurationRecordViewDto getConfigurationRecordView(String schemaId, St checkSchemaId(schemaId); ConfigurationRecordDto record = getConfigurationRecord(schemaId, endpointGroupId); return toConfigurationRecordView(record); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -307,8 +307,8 @@ public ConfigurationRecordFormDto editConfigurationRecordForm(ConfigurationRecor ConfigurationDto toSave = toConfigurationDto(configuration); ConfigurationDto stored = editConfiguration(toSave); return toConfigurationRecordFormDto(stored); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -318,8 +318,8 @@ public ConfigurationRecordFormDto activateConfigurationRecordForm(String configu try { ConfigurationDto storedConfiguration = activateConfiguration(configurationId); return toConfigurationRecordFormDto(storedConfiguration); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -329,8 +329,8 @@ public ConfigurationRecordFormDto deactivateConfigurationRecordForm(String confi try { ConfigurationDto storedConfiguration = deactivateConfiguration(configurationId); return toConfigurationRecordFormDto(storedConfiguration); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -344,8 +344,8 @@ public RecordField getConfigurationRecordDataFromFile(String schema, String file GenericAvroConverter converter = new GenericAvroConverter<>(schema); GenericRecord record = converter.decodeJson(body); return FormAvroConverter.createRecordFieldFromGenericRecord(record); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -364,8 +364,8 @@ public List getUserConfigurationSchemaInfosByApplicationId(String schemaInfos.add(schemaInfo); } return schemaInfos; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -381,8 +381,8 @@ public void editUserConfiguration(EndpointUserConfigurationDto endpointUserConfi String body = converter.encodeToJson(record); endpointUserConfiguration.setBody(body); controlService.editUserConfiguration(endpointUserConfiguration); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -393,8 +393,8 @@ public List getVacantConfigurationSchemaInfosByEndpointGroupId(St EndpointGroupDto endpointGroup = checkEndpointGroupId(endpointGroupId); List schemas = getVacantConfigurationSchemasByEndpointGroupId(endpointGroupId); return toConfigurationSchemaInfos(schemas, endpointGroup); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -411,8 +411,8 @@ public ConfigurationSchemaViewDto createConfigurationSchemaFormCtlSchema(CtlSche confSchema.setCtlSchemaId(savedCtlSchemaForm.getId()); ConfigurationSchemaDto savedConfSchema = saveConfigurationSchema(confSchema); return getConfigurationSchemaView(savedConfSchema.getId()); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -432,8 +432,8 @@ public EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppToke throw Utils.handleException(new KaaAdminServiceException("could not find user configuration", ITEM_NOT_FOUND)); } return userConfigurationDto; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -447,8 +447,8 @@ public EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppIdAn throw Utils.handleException(new KaaAdminServiceException("could not find user configuration", ITEM_NOT_FOUND)); } return userConfigurationDto; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/NotificationServiceImpl.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/NotificationServiceImpl.java index cb1ee4150f..cac77c0498 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/NotificationServiceImpl.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/NotificationServiceImpl.java @@ -76,8 +76,8 @@ public List getNotificationSchemasByApplicationId(String try { checkApplicationId(applicationId); return controlService.findNotificationSchemasByAppIdAndType(applicationId, NotificationTypeDto.USER); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -92,8 +92,8 @@ public List getUserNotificationSchemasByApplicationId(String applica try { checkApplicationId(applicationId); return controlService.getUserNotificationSchemasByAppId(applicationId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -104,8 +104,8 @@ public NotificationSchemaDto getNotificationSchema(String notificationSchemaId) Utils.checkNotNull(notificationSchema); checkApplicationId(notificationSchema.getApplicationId()); return notificationSchema; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -124,8 +124,8 @@ public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notifi } notificationSchema.setType(NotificationTypeDto.USER); return controlService.saveNotificationSchema(notificationSchema); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -140,8 +140,8 @@ public List getTopicsByApplicationId(String applicationId) throws KaaA try { checkApplicationId(applicationId); return controlService.getTopicByAppId(applicationId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -151,8 +151,8 @@ public List getTopicsByEndpointGroupId(String endpointGroupId) throws try { checkEndpointGroupId(endpointGroupId); return controlService.getTopicByEndpointGroupId(endpointGroupId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -162,8 +162,8 @@ public List getVacantTopicsByEndpointGroupId(String endpointGroupId) t try { checkEndpointGroupId(endpointGroupId); return controlService.getVacantTopicByEndpointGroupId(endpointGroupId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -175,8 +175,8 @@ public TopicDto getTopic(String topicId) throws KaaAdminServiceException { Utils.checkNotNull(topic); checkApplicationId(topic.getApplicationId()); return topic; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -191,8 +191,8 @@ public TopicDto editTopic(TopicDto topic) throws KaaAdminServiceException { throw new KaaAdminServiceException("Unable to edit existing topic!", ServiceErrorCode.INVALID_ARGUMENTS); } return controlService.editTopic(topic); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -205,8 +205,8 @@ public void deleteTopic(String topicId) throws KaaAdminServiceException { Utils.checkNotNull(topic); checkApplicationId(topic.getApplicationId()); controlService.deleteTopicById(topicId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -220,8 +220,8 @@ public void addTopicToEndpointGroup(String endpointGroupId, String topicId) thro Utils.checkNotNull(topic); checkApplicationId(topic.getApplicationId()); controlService.addTopicsToEndpointGroup(endpointGroupId, topicId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -235,8 +235,8 @@ public void removeTopicFromEndpointGroup(String endpointGroupId, String topicId) Utils.checkNotNull(topic); checkApplicationId(topic.getApplicationId()); controlService.removeTopicsFromEndpointGroup(endpointGroupId, topicId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -251,8 +251,8 @@ public NotificationDto sendNotification(NotificationDto notification, byte[] bod Utils.checkNotNull(topic); checkApplicationId(topic.getApplicationId()); return controlService.editNotification(notification); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -271,8 +271,8 @@ public EndpointNotificationDto sendUnicastNotification(NotificationDto notificat unicastNotification.setEndpointKeyHash(Base64.decode(clientKeyHash.getBytes(Charsets.UTF_8))); unicastNotification.setNotificationDto(notification); return controlService.editUnicastNotification(unicastNotification); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -303,8 +303,8 @@ public List getUserNotificationSchemaInfosByApplicationId(String schemaInfos.add(schemaInfo); } return schemaInfos; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -317,8 +317,8 @@ public NotificationSchemaViewDto getNotificationSchemaView(String notificationSc NotificationSchemaViewDto notificationSchemaViewDto = new NotificationSchemaViewDto(notificationSchema, toCtlSchemaForm(ctlSchemaDto, ConverterType.FORM_AVRO_CONVERTER)); return notificationSchemaViewDto; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -345,8 +345,8 @@ public NotificationSchemaViewDto saveNotificationSchemaView(NotificationSchemaVi } NotificationSchemaDto savedNotificationSchema = saveNotificationSchema(notificationSchema); return getNotificationSchemaView(savedNotificationSchema.getId()); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -364,8 +364,8 @@ public NotificationSchemaViewDto createNotificationSchemaFormCtlSchema(CtlSchema notificationSchema.setCtlSchemaId(savedCtlSchemaForm.getId()); NotificationSchemaDto savedNotificationSchema = saveNotificationSchema(notificationSchema); return getNotificationSchemaView(savedNotificationSchema.getId()); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -383,8 +383,8 @@ public void sendNotification(NotificationDto notification, RecordField notificat Utils.checkNotNull(topic); checkApplicationId(topic.getApplicationId()); controlService.editNotification(notification); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -397,8 +397,8 @@ public EndpointNotificationDto sendUnicastNotification(NotificationDto notificat GenericAvroConverter converter = new GenericAvroConverter<>(record.getSchema()); byte[] body = converter.encodeToJsonBytes(record); return sendUnicastNotification(notification, clientKeyHash, body); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/ProfileServiceImpl.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/ProfileServiceImpl.java index 4c6ba7b2de..577afbb2d8 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/ProfileServiceImpl.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/ProfileServiceImpl.java @@ -89,8 +89,8 @@ public List getProfileSchemasByApplicationId(String ap try { checkApplicationId(applicationId); return controlService.getProfileSchemasByApplicationId(applicationId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -102,8 +102,8 @@ public EndpointProfileSchemaDto getProfileSchema(String profileSchemaId) throws Utils.checkNotNull(profileSchema); checkApplicationId(profileSchema.getApplicationId()); return profileSchema; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -120,8 +120,8 @@ public EndpointProfileSchemaDto saveProfileSchema(EndpointProfileSchemaDto profi checkApplicationId(storedProfileSchema.getApplicationId()); } return controlService.editProfileSchema(profileSchema); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -136,8 +136,8 @@ public List getServerProfileSchemasByApplicationId(Strin try { checkApplicationId(applicationId); return controlService.getServerProfileSchemasByApplicationId(applicationId); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -149,8 +149,8 @@ public ServerProfileSchemaDto getServerProfileSchema(String serverProfileSchemaI Utils.checkNotNull(profileSchema); checkApplicationId(profileSchema.getApplicationId()); return profileSchema; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -167,8 +167,8 @@ public ServerProfileSchemaDto saveServerProfileSchema(ServerProfileSchemaDto ser checkApplicationId(storedServerProfileSchema.getApplicationId()); } return controlService.saveServerProfileSchema(serverProfileSchema); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -188,18 +188,18 @@ public EndpointProfileDto updateServerProfile(String endpointKeyHash, try { record = createRecordFieldFromCtlSchemaAndBody(serverProfileSchema.getCtlSchemaId(), serverProfileBody); - } catch (Exception e) { - LOG.error("Provided server profile body is not valid: ", e); + } catch (Exception ex) { + LOG.error("Provided server profile body is not valid: ", ex); throw new KaaAdminServiceException("Provided server profile body is not valid: " - + e.getMessage(), ServiceErrorCode.BAD_REQUEST_PARAMS); + + ex.getMessage(), ServiceErrorCode.BAD_REQUEST_PARAMS); } if (!record.isValid()) { throw new KaaAdminServiceException("Provided server profile body is not valid!", ServiceErrorCode.BAD_REQUEST_PARAMS); } profileDto = controlService.updateServerProfile(endpointKeyHash, serverProfileVersion, serverProfileBody); return profileDto; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -213,8 +213,8 @@ public EndpointProfileDto getEndpointProfileByKeyHash(String endpointProfileKeyH } checkApplicationId(profileDto.getApplicationId()); return profileDto; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -226,8 +226,8 @@ public EndpointProfileBodyDto getEndpointProfileBodyByKeyHash(String endpointPro Utils.checkNotNull(profileBodyDto); checkApplicationId(profileBodyDto.getAppId()); return profileBodyDto; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -282,8 +282,8 @@ public ProfileSchemaViewDto saveProfileSchemaView(ProfileSchemaViewDto profileSc } EndpointProfileSchemaDto savedProfileSchema = saveProfileSchema(profileSchema); return getProfileSchemaView(savedProfileSchema.getId()); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -301,8 +301,8 @@ public ProfileSchemaViewDto createProfileSchemaFormCtlSchema(CtlSchemaFormDto ct profileSchema.setCtlSchemaId(savedCtlSchemaForm.getId()); EndpointProfileSchemaDto savedProfileSchema = saveProfileSchema(profileSchema); return getProfileSchemaView(savedProfileSchema.getId()); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -313,8 +313,8 @@ public ProfileSchemaViewDto getProfileSchemaView(String profileSchemaId) throws EndpointProfileSchemaDto profileSchema = getProfileSchema(profileSchemaId); CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(profileSchema.getCtlSchemaId()); return new ProfileSchemaViewDto(profileSchema, toCtlSchemaForm(ctlSchemaDto, ConverterType.FORM_AVRO_CONVERTER)); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -333,8 +333,8 @@ public List getServerProfileSchemaInfosByApplicationId(String app schemaInfos.add(schemaInfo); } return schemaInfos; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -358,8 +358,8 @@ public List getServerProfileSchemaInfosByEndpointKey(String endpo } Collections.sort(schemaInfos, Collections.reverseOrder()); return schemaInfos; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -370,8 +370,8 @@ public ServerProfileSchemaViewDto getServerProfileSchemaView(String serverProfil ServerProfileSchemaDto serverProfileSchema = getServerProfileSchema(serverProfileSchemaId); CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(serverProfileSchema.getCtlSchemaId()); return new ServerProfileSchemaViewDto(serverProfileSchema, toCtlSchemaForm(ctlSchemaDto, ConverterType.FORM_AVRO_CONVERTER)); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -398,8 +398,8 @@ public ServerProfileSchemaViewDto saveServerProfileSchemaView(ServerProfileSchem } ServerProfileSchemaDto savedServerProfileSchema = saveServerProfileSchema(serverProfileSchema); return getServerProfileSchemaView(savedServerProfileSchema.getId()); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -417,8 +417,8 @@ public ServerProfileSchemaViewDto createServerProfileSchemaFormCtlSchema(CtlSche serverProfileSchema.setCtlSchemaId(savedCtlSchemaForm.getId()); ServerProfileSchemaDto savedServerProfileSchema = saveServerProfileSchema(serverProfileSchema); return getServerProfileSchemaView(savedServerProfileSchema.getId()); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -432,8 +432,8 @@ public SchemaInfoDto getEndpointProfileSchemaInfo(String endpointProfileSchemaId schemaInfo.setSchemaName(endpointProfileSchema.getName()); schemaInfo.setSchemaForm(schemaForm); return schemaInfo; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -447,8 +447,8 @@ public SchemaInfoDto getServerProfileSchemaInfo(String serverProfileSchemaId) th schemaInfo.setSchemaName(serverProfileSchema.getName()); schemaInfo.setSchemaForm(schemaForm); return schemaInfo; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -465,8 +465,8 @@ public boolean testProfileFilter(RecordField endpointProfile, RecordField server if (serverProfile != null) { serverProfileRecord = FormAvroConverter.createGenericRecordFromRecordField(serverProfile); } - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } try { Expression expression = new SpelExpressionParser().parseExpression(filterBody); @@ -483,11 +483,11 @@ public boolean testProfileFilter(RecordField endpointProfile, RecordField server evaluationContext.setVariable(DefaultFilterEvaluator.SERVER_PROFILE_VARIABLE_NAME, serverProfileRecord); } return expression.getValue(evaluationContext, Boolean.class); - } catch (Exception e) { - throw new KaaAdminServiceException("Invalid profile filter: " + e.getMessage(), e, ServiceErrorCode.BAD_REQUEST_PARAMS); + } catch (Exception ex) { + throw new KaaAdminServiceException("Invalid profile filter: " + ex.getMessage(), ex, ServiceErrorCode.BAD_REQUEST_PARAMS); } - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -550,8 +550,8 @@ public EndpointProfileViewDto getEndpointProfileViewByKeyHash(String endpointPro List endpointGroups = new ArrayList(endpointGroupsSet); endpointProfileView.setEndpointGroups(endpointGroups); return endpointProfileView; - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -565,8 +565,8 @@ public EndpointProfileDto updateServerProfile(String endpointKeyHash, GenericAvroConverter converter = new GenericAvroConverter(record.getSchema()); String serverProfileBody = converter.encodeToJson(record); return updateServerProfile(endpointKeyHash, serverProfileVersion, serverProfileBody); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } }