You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Mikhail Stepura (JIRA)" <ji...@apache.org> on 2014/02/05 22:56:10 UTC
[jira] [Commented] (CASSANDRA-6656) Exception logging
[ https://issues.apache.org/jira/browse/CASSANDRA-6656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13892620#comment-13892620 ]
Mikhail Stepura commented on CASSANDRA-6656:
--------------------------------------------
[~d.yuan] My comments
* Case1 (Hex.java): Do you really need a full stack trace there? (you use {{error(String, Throwable)}} version)
* Case2 (DynamicCompositeType.java) Use parameterized messages instead of strings concatenation (http://www.slf4j.org/faq.html#logging_performance )
* Case3 (NodeProbe.java): Use provided {{PrintStream out}} instead of calling {{System.out}} directly
> Exception logging
> -----------------
>
> Key: CASSANDRA-6656
> URL: https://issues.apache.org/jira/browse/CASSANDRA-6656
> Project: Cassandra
> Issue Type: Improvement
> Components: Core, Tools
> Reporter: Ding Yuan
> Assignee: Ding Yuan
> Priority: Trivial
> Fix For: 2.1
>
> Attachments: trunk-6656.txt
>
>
> Reporting a few cases where informative exceptions can be silently swallowed. Attaching a proposed patch.
> =========================
> Case 1
> Line: 95, File: "org/apache/cassandra/utils/Hex.java"
> An actual failure in the underlying constructor will be lost.
> Propose to log it.
> {noformat}
> try
> {
> s = stringConstructor.newInstance(0, c.length, c);
> + }
> + catch (InvocationTargetException ite) {
> + // The underlying constructor failed. Unwrapping the exception.
> + logger.info("Underlying constructor throws exception: ", ite.getCause());
> }
> catch (Exception e)
> {
> // Swallowing as we'll just use a copying constructor
> }
> return s == null ? new String(c) : s;
> {noformat}
> ==========================================
> =========================
> Case 2
> Line: 192, File: "org/apache/cassandra/db/marshal/DynamicCompositeType.java"
> The actual cause of comparator error can be lost as it can fail in multiple locations.
> {noformat}
> AbstractType<?> comparator = null;
> int header = getShortLength(bb);
> if ((header & 0x8000) == 0)
> {
> ByteBuffer value = getBytes(bb, header);
> try
> {
> comparator = TypeParser.parse(ByteBufferUtil.string(value));
> }
> catch (Exception e)
> {
> <--- can fail here
> // we'll deal with this below since comparator == null
> }
> }
> else
> {
> comparator = aliases.get((byte)(header & 0xFF));
> <--- can fail here
> }
> if (comparator == null)
> throw new MarshalException("Cannot find comparator for component " + i);
> {noformat}
> Propose to log the exception.
> ==========================================
> =========================
> Case 3
> Line: 239, File: "org/apache/cassandra/tools/NodeProbe.java"
> Exception ignored in finally. Propose log them with debug or trace.
> {noformat}
> 232: finally
> 233: {
> 234: try
> 235: {
> 236: ssProxy.removeNotificationListener(runner);
> 236: ssProxy.removeNotificationListener(runner);
> 237: jmxc.removeConnectionNotificationListener(runner);
> 238: }
> 239: catch (Throwable ignored) {}
> 240: }
> {noformat}
> Similar case is at line 264 in the same file.
> ==========================================
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)