mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-04 19:56:49 +02:00
SONAR suggestion - log exceptions, don't print stack traces
Change-Id: I4814a0662912706df005972d44c48a7db39ecd50
This commit is contained in:
parent
961b19f66d
commit
ba547f9158
@ -399,7 +399,7 @@ public class ArtemisConfig extends Config<ApplicationId> {
|
||||
try {
|
||||
asnPath.add(path.getInt(i));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("checkPath", e);
|
||||
}
|
||||
}
|
||||
// reverse the list to get path starting from origin
|
||||
|
||||
@ -23,7 +23,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.apache.felix.scr.annotations.Activate;
|
||||
import org.apache.felix.scr.annotations.Component;
|
||||
import org.apache.felix.scr.annotations.Deactivate;
|
||||
@ -395,8 +394,7 @@ public class ArtemisDeaggregatorImpl implements ArtemisDeaggregator {
|
||||
ByteBuf buffer = Unpooled.copiedBuffer(jsonInString, CharsetUtil.UTF_8);
|
||||
ctx.writeAndFlush(buffer);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
log.warn(ExceptionUtils.getFullStackTrace(e));
|
||||
log.warn("processMoasPacket()", e);
|
||||
}
|
||||
|
||||
remoteTunnelIp = IpAddress.valueOf(msg.getLocalIp());
|
||||
|
||||
@ -24,7 +24,6 @@ import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onosproject.artemis.ArtemisPacketProcessor;
|
||||
@ -69,8 +68,7 @@ public class MoasClientHandler extends ChannelInboundHandlerAdapter {
|
||||
ByteBuf buffer = Unpooled.copiedBuffer(jsonInString, CharsetUtil.UTF_8);
|
||||
ctx.writeAndFlush(buffer);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
log.warn(ExceptionUtils.getFullStackTrace(e));
|
||||
log.warn("channelActive()", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,8 +85,7 @@ public class MoasClientHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
log.error(ExceptionUtils.getFullStackTrace(cause));
|
||||
cause.printStackTrace();
|
||||
log.error("exceptionCaught()", cause);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onosproject.artemis.impl.objects.ArtemisMessage;
|
||||
import org.slf4j.Logger;
|
||||
@ -77,8 +76,7 @@ public class MoasServerHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
log.error(ExceptionUtils.getFullStackTrace(cause));
|
||||
cause.printStackTrace();
|
||||
log.error("exceptionCaught()", cause);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ public class ExaBgpMonitors implements Monitors {
|
||||
|
||||
socket.emit("exa_subscribe", parameters);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("onConenct()", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class ExaBgpMonitors implements Monitors {
|
||||
packetProcessor.processMonitorPacket(message);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("onExaMessage()", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ public class ExaBgpMonitors implements Monitors {
|
||||
this.socket.on(Socket.EVENT_PING, args -> socket.emit("pong"));
|
||||
this.socket.on("exa_message", this::onExaMessage);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("startMonitor()", e);
|
||||
}
|
||||
this.socket.connect();
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@ package org.onosproject.artemis.impl.monitors;
|
||||
|
||||
import io.socket.client.IO;
|
||||
import io.socket.client.Socket;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
@ -63,7 +62,7 @@ public class RipeMonitors implements Monitors {
|
||||
|
||||
socket.emit("ris_subscribe", parameters);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("onConnect()", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,8 +109,7 @@ public class RipeMonitors implements Monitors {
|
||||
packetProcessor.processMonitorPacket(message);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error(ExceptionUtils.getFullStackTrace(e));
|
||||
e.printStackTrace();
|
||||
log.error("onRisMessage()", e);
|
||||
}
|
||||
socket.emit("ping");
|
||||
}
|
||||
@ -129,8 +127,7 @@ public class RipeMonitors implements Monitors {
|
||||
this.socket.on(Socket.EVENT_PONG, args -> socket.emit("ping"));
|
||||
this.socket.on("ris_message", this::onRisMessage);
|
||||
} catch (URISyntaxException e) {
|
||||
log.error(ExceptionUtils.getFullStackTrace(e));
|
||||
e.printStackTrace();
|
||||
log.error("startMonitor()", e);
|
||||
}
|
||||
|
||||
this.socket.connect();
|
||||
|
||||
@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onosproject.rest.AbstractWebResource;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
@ -88,8 +89,7 @@ public class CastorWebResource extends AbstractWebResource {
|
||||
get(ArpService.class).createArp(peer);
|
||||
arpResult = ", ARP packet sent, MAC was not known";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
String result = "Unable to process due to some reason, Try again";
|
||||
ObjectNode node = mapper().createObjectNode().put("response", result);
|
||||
return ok(node).build();
|
||||
@ -117,8 +117,7 @@ public class CastorWebResource extends AbstractWebResource {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Peer peer = mapper.readValue(incomingData, Peer.class);
|
||||
get(ConnectivityManagerService.class).deletePeer(peer);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
return Response.status(500).entity("Unable to delete the peer").build();
|
||||
}
|
||||
String result = "Peer Deleted";
|
||||
@ -143,8 +142,7 @@ public class CastorWebResource extends AbstractWebResource {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Peer peer = mapper.readValue(incomingData, Peer.class);
|
||||
get(ConnectivityManagerService.class).start(peer);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
return Response.status(500).entity("Unable to add the route server").build();
|
||||
}
|
||||
String result = "Server Entered";
|
||||
|
||||
@ -648,7 +648,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
|
||||
recordSemaphore.release();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@ -807,7 +807,7 @@ public class Dhcp6HandlerImpl implements DhcpHandler, HostProvider {
|
||||
recordSemaphore.release();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -77,9 +77,9 @@ public class KafkaStorageManager implements KafkaEventStorageService {
|
||||
try {
|
||||
task = future.get();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("consumeEvent()", e);
|
||||
}
|
||||
|
||||
if (task != null) {
|
||||
|
||||
@ -194,7 +194,7 @@ public class NetconfActiveComponent implements DynamicConfigListener {
|
||||
return netconfTranslator.editDeviceConfig(
|
||||
deviceId, builder.build(), operationType);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.debug("parseAndEdit()", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,8 +93,8 @@ import static org.onosproject.yang.runtime.SerializerHelper.addDataNode;
|
||||
@Component(immediate = true)
|
||||
public class NetconfTranslatorImpl implements NetconfTranslator {
|
||||
|
||||
private final Logger log = LoggerFactory
|
||||
.getLogger(getClass());
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(NetconfTranslator.class);
|
||||
|
||||
private NodeId localNodeId;
|
||||
|
||||
@ -354,7 +354,7 @@ public class NetconfTranslatorImpl implements NetconfTranslator {
|
||||
try {
|
||||
rIdBldr = rid.copyBuilder();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
log.debug("clone not supported", e);
|
||||
}
|
||||
} else {
|
||||
rIdBldr.addBranchPointSchema("/", null);
|
||||
|
||||
@ -108,7 +108,7 @@ public final class Utils {
|
||||
try {
|
||||
transformer = transformerFactory.newTransformer();
|
||||
} catch (TransformerConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
|
||||
// Need to omit the xml header and set indent to 4
|
||||
@ -122,7 +122,7 @@ public final class Utils {
|
||||
try {
|
||||
transformer.transform(xmlInput, xmlOutput);
|
||||
} catch (TransformerException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return xmlOutput.getWriter().toString();
|
||||
|
||||
@ -109,9 +109,7 @@ public class Ea1000DeviceDescription extends AbstractHandlerBehaviour implements
|
||||
latitudeStr = augmentedSystem.latitude().toPlainString();
|
||||
}
|
||||
} catch (NetconfException e) {
|
||||
log.error("Unable to retrieve init data from device: " + handler().data().deviceId().toString()
|
||||
+ " Error: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
log.error("Unable to retrieve init data from device: " + handler().data().deviceId().toString(), e);
|
||||
}
|
||||
|
||||
DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
|
||||
|
||||
@ -25,6 +25,8 @@ import org.onosproject.incubator.net.virtual.provider.VirtualProviderRegistrySer
|
||||
import org.onosproject.incubator.net.virtual.provider.VirtualProviderService;
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.onosproject.net.provider.ProviderId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -47,6 +49,7 @@ public class VirtualProviderManager
|
||||
private final Map<ProviderId, VirtualProviderService> servicesWithProvider = new HashMap<>();
|
||||
private final Map<String, VirtualProvider> providersByScheme = new HashMap<>();
|
||||
private final Map<NetworkId, Set<VirtualProviderService>> servicesByNetwork = new HashMap<>();
|
||||
private static Logger log = LoggerFactory.getLogger(VirtualProviderManager.class);
|
||||
|
||||
@Override
|
||||
public synchronized void registerProvider(VirtualProvider virtualProvider) {
|
||||
@ -160,7 +163,7 @@ public class VirtualProviderManager
|
||||
try {
|
||||
return Class.forName(pramType);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("getProviderClass()", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@ -243,7 +243,7 @@ public class NetconfStreamThread extends Thread implements NetconfStreamHandler
|
||||
try {
|
||||
bufferReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -377,7 +377,7 @@ public class HttpSBControllerImpl implements HttpSBController {
|
||||
}
|
||||
} }, new java.security.SecureRandom());
|
||||
} catch (NoSuchAlgorithmException | KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
return ClientBuilder.newBuilder().sslContext(sslcontext).hostnameVerifier((s1, s2) -> true).build();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user