Skip to content

Commit

Permalink
sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rjpmestre committed Oct 25, 2024
1 parent 1dbcc5c commit 0e3c788
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private ErrorReportingStrategies() {
* @return Supplier of RhnRuntimeException that logs the message and throw the exception
*/
public static Supplier<RhnRuntimeException> raiseAndLog(Object obj, String message) {
Logger logger = OBJ_LOGGER.computeIfAbsent(obj, (key) -> LogManager.getLogger(obj.getClass().getName()));
Logger logger = OBJ_LOGGER.computeIfAbsent(obj, key -> LogManager.getLogger(obj.getClass().getName()));
return () -> {
logger.error(message);
return new RhnRuntimeException(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.dto.SystemOverview;
import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
import com.redhat.rhn.frontend.xmlrpc.IOFaultException;
import com.redhat.rhn.frontend.xmlrpc.InvalidParameterException;
import com.redhat.rhn.frontend.xmlrpc.InvalidProxyVersionException;
import com.redhat.rhn.frontend.xmlrpc.MethodInvalidParamException;
Expand All @@ -34,7 +33,6 @@
import com.redhat.rhn.frontend.xmlrpc.ProxyNotActivatedException;
import com.redhat.rhn.frontend.xmlrpc.ProxySystemIsSatelliteException;
import com.redhat.rhn.frontend.xmlrpc.SSLCertFaultException;
import com.redhat.rhn.frontend.xmlrpc.SystemIdInstantiationException;
import com.redhat.rhn.frontend.xmlrpc.system.XmlRpcSystemHelper;
import com.redhat.rhn.manager.entitlement.EntitlementManager;
import com.redhat.rhn.manager.system.SystemManager;
Expand All @@ -48,7 +46,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -297,14 +294,6 @@ public byte[] containerConfig(User loggedInUser, String proxyName, Integer proxy
maxCache.longValue(), email, rootCA, intermediateCAs, proxyCrtKey, null, null, null,
new SSLCertManager());
}
catch (InstantiationException e) {
LOG.error("Failed to generate proxy system id", e);
throw new SystemIdInstantiationException();
}
catch (IOException e) {
LOG.error("Failed to generate container config", e);
throw new IOFaultException(e);
}
catch (SSLCertGenerationException e) {
LOG.error("Failed to generate SSL certificate", e);
throw new SSLCertFaultException(e.getMessage());
Expand Down Expand Up @@ -369,14 +358,6 @@ public byte[] containerConfig(User loggedInUser, String proxyName, Integer proxy
maxCache.longValue(), email, null, List.of(), null, caCrtKey, caPassword, certData,
new SSLCertManager());
}
catch (InstantiationException e) {
LOG.error("Failed to generate proxy system id", e);
throw new SystemIdInstantiationException();
}
catch (IOException e) {
LOG.error("Failed to generate container config", e);
throw new IOFaultException(e);
}
catch (SSLCertGenerationException e) {
LOG.error("Failed to generate SSL certificate", e);
throw new SSLCertFaultException(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
import org.apache.logging.log4j.Logger;
import org.hibernate.Session;

import java.io.IOException;
import java.net.IDN;
import java.security.SecureRandom;
import java.sql.Date;
Expand Down Expand Up @@ -2155,7 +2154,7 @@ public byte[] createProxyContainerConfig(User user, String proxyName, Integer pr
SSLCertPair proxyCertKey,
SSLCertPair caPair, String caPassword, SSLCertData certData,
SSLCertManager certManager)
throws IOException, InstantiationException, SSLCertGenerationException {
throws SSLCertGenerationException {

return new ProxyContainerConfigCreate().create(
saltApi, systemEntitlementManager, user, server, proxyName, proxyPort, maxCache, email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import com.suse.manager.webui.services.impl.runner.MgrUtilRunner;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.security.SecureRandom;
import java.util.HashSet;
Expand All @@ -53,7 +51,6 @@
* Acquires and validates all necessary data for the Proxy container configuration creation files.
*/
public class ProxyContainerConfigCreateAcquisitor implements ProxyContainerConfigCreateContextHandler {
private static final Logger LOG = LogManager.getLogger(SystemManagerUtils.class);

private SaltApi saltApi;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
import com.suse.manager.webui.services.iface.SaltApi;
import com.suse.manager.webui.services.impl.runner.MgrUtilRunner;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -37,8 +34,6 @@
*/
public class ProxyContainerConfigCreateContext {

private static final Logger LOG = LogManager.getLogger(ProxyContainerConfigCreateContext.class);

// provided
private final SaltApi saltApi;
private final User user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -126,11 +125,6 @@ public String generateContainerConfig(Request request, Response response, User u

return SparkApplicationHelper.json(response, filename + "-config.tar.gz");
}
catch (IOException | InstantiationException e) {
LOG.error("Failed to generate proxy container configuration", e);
return jsonError(response, HttpStatus.SC_INTERNAL_SERVER_ERROR,
"Failed to generate proxy container configuration");
}
catch (SystemsExistException e) {
String msg = String.format("Cannot create proxy as an existing system has FQDN '%s'", data.getProxyFqdn());
LOG.error(msg);
Expand Down

0 comments on commit 0e3c788

Please sign in to comment.