5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-16 08:51:02 +08:00

SQOOP-2485: Sqoop2: Findbugs: Fix smaller-ish warnings in core module

(Colin Ma via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2015-08-20 09:19:24 -07:00
parent 5b5042c1f2
commit b62c3dec82
8 changed files with 24 additions and 26 deletions

View File

@ -63,15 +63,6 @@ public static AuditLoggerManager getInstance() {
return instance;
}
/**
* Allows to set instance in case that it's need.
*
* @param newInstance New instance
*/
public void setInstance(AuditLoggerManager newInstance) {
instance = newInstance;
}
public AuditLoggerManager() {
loggers = new ArrayList<AuditLogger>();
}
@ -95,10 +86,11 @@ private void initializeLoggers() {
AuditLoggerConstants.PREFIX_AUDITLOGGER_CONFIG);
// Initialize audit loggers
for (String key : auditLoggerProps.keySet()) {
for (Map.Entry<String, String> entry : auditLoggerProps.entrySet()) {
String key = entry.getKey();
if (key.endsWith(AuditLoggerConstants.SUFFIX_AUDITLOGGER_CLASS)) {
String loggerName = key.substring(0, key.indexOf("."));
String loggerClassName = auditLoggerProps.get(key);
String loggerClassName = entry.getValue();
if (loggerClassName == null || loggerClassName.trim().length() == 0) {
throw new SqoopException(AuditLoggerError.AUDIT_0001,

View File

@ -196,8 +196,8 @@ private synchronized void registerConnectors(boolean autoUpgrade) {
try {
rtx = repository.getTransaction();
rtx.begin();
for (String name : handlerMap.keySet()) {
ConnectorHandler handler = handlerMap.get(name);
for (Map.Entry<String, ConnectorHandler> entry : handlerMap.entrySet()) {
ConnectorHandler handler = entry.getValue();
MConnector newConnector = handler.getConnectorConfigurable();
MConnector registeredConnector = repository.registerConnector(newConnector, autoUpgrade);
// Set the registered connector in the database to the connector configurable instance

View File

@ -159,7 +159,7 @@ private synchronized boolean isShutdown() {
private synchronized void loadSleepTime() {
try {
String value = configuration.get(PROPERTIES_PROVIDER_SLEEP);
sleepTime = Long.valueOf(value);
sleepTime = Long.parseLong(value);
} catch(Exception e) {
LOG.debug("Can't load sleeping period from configuration file,"
+ " using default value " + DEFAULT_SLEEP_TIME, e);

View File

@ -19,6 +19,7 @@
import org.apache.log4j.Logger;
import org.apache.sqoop.audit.AuditLoggerManager;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.ConnectorManager;
import org.apache.sqoop.driver.Driver;
import org.apache.sqoop.driver.JobManager;
@ -58,9 +59,9 @@ public static void initialize() {
Driver.getInstance().initialize();
JobManager.getInstance().initialize();
LOG.info("Sqoop server has successfully boot up");
} catch (Exception ex) {
LOG.error("Server startup failure", ex);
throw new RuntimeException("Failure in server initialization", ex);
} catch (RuntimeException | ClassNotFoundException | IllegalAccessException | InstantiationException e) {
LOG.error("Server startup failure", e);
throw new RuntimeException("Failure in server initialization", e);
}
}
}

View File

@ -279,7 +279,7 @@ public MSubmission start(long jobId, HttpEventContext ctx) {
prepareJob(jobRequest);
// Make sure that this job id is not currently running and submit the job
// only if it's not.
synchronized (getClass()) {
synchronized (JobManager.class) {
MSubmission lastSubmission = RepositoryManager.getInstance().getRepository()
.findLastSubmissionForJob(jobId);
if (lastSubmission != null && lastSubmission.getStatus().isRunning()) {
@ -561,8 +561,8 @@ void invokeDestroyerOnJobSuccess(MSubmission submission) {
}
RepositoryManager.getInstance().getRepository().updateJob(job);
} catch(Exception ex) {
LOG.error("Exception when invoking destroyer on job success", ex);
} catch (RuntimeException e) {
LOG.error("RuntimeException when invoking destroyer on job success", e);
submission.setStatus(SubmissionStatus.FAILED);
}
}

View File

@ -729,7 +729,7 @@ public Object doIt(Connection conn) {
*/
@Override
public void updateJobConfig(final long jobId, final MConfig config, final MConfigUpdateEntityType type) {
updateJobConfig(jobId, config, null);
updateJobConfig(jobId, config, type, null);
}
/**
* {@inheritDoc}

View File

@ -18,6 +18,7 @@
package org.apache.sqoop.repository;
import java.sql.Connection;
import java.util.Locale;
public enum JdbcTransactionIsolation {
@ -50,6 +51,6 @@ public static JdbcTransactionIsolation getByName(String name) {
if (name == null || name.trim().length() == 0) {
return null;
}
return valueOf(name.trim().toUpperCase());
return valueOf(name.trim().toUpperCase(Locale.getDefault()));
}
}

View File

@ -459,11 +459,15 @@ public abstract class Repository {
protected abstract void deleteLinkInputs(long linkId, RepositoryTransaction tx);
private void deletelinksAndJobInputs(List<MLink> links, List<MJob> jobs, RepositoryTransaction tx) {
for (MJob job : jobs) {
deleteJobInputs(job.getPersistenceId(), tx);
if (jobs != null) {
for (MJob job : jobs) {
deleteJobInputs(job.getPersistenceId(), tx);
}
}
for (MLink link : links) {
deleteLinkInputs(link.getPersistenceId(), tx);
if (links != null) {
for (MLink link : links) {
deleteLinkInputs(link.getPersistenceId(), tx);
}
}
}