Skip to content

Commit

Permalink
[JENKINS-21289] Item Logging causing NPE
Browse files Browse the repository at this point in the history
getLevel() return <null> when no logger is configured.
  • Loading branch information
emsa23 committed Jan 8, 2014
1 parent 444dc15 commit abc2cc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/java/jenkins/advancedqueue/ItemTransitionLogger.java
Expand Up @@ -27,6 +27,7 @@
import java.util.logging.Logger;

import jenkins.advancedqueue.sorter.ItemInfo;
import jenkins.model.Jenkins;

/**
* @author Magnus Sandberg
Expand All @@ -37,8 +38,7 @@ public class ItemTransitionLogger {
private final static Logger LOGGER = Logger.getLogger("PrioritySorter.Queue.Items");

static public void logNewItem(ItemInfo info) {
if (LOGGER.getLevel().intValue() == Level.ALL.intValue()
|| LOGGER.getLevel().intValue() >= Level.FINER.intValue()) {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("New Item: " + info.toString() + "\n" + info.getDescisionLog());
} else {
LOGGER.fine("New Item: " + info.toString());
Expand Down
Expand Up @@ -92,14 +92,11 @@ public int compare(BuildableItem o1, BuildableItem o2) {
}
});
//
if (items.size() > 0
&& (LOGGER.getLevel().intValue() >= Level.FINE.intValue() || LOGGER.getLevel().intValue() == Level.ALL
.intValue())) {
if (items.size() > 0 && LOGGER.isLoggable(Level.FINE)) {
float minWeight = QueueItemCache.get().getItem(items.get(0).id).getWeight();
float maxWeight = QueueItemCache.get().getItem(items.get(items.size() - 1).id).getWeight();
LOGGER.log(Level.INFO, "Sorted {0} Buildable Items with Min Weight {1} and Max Weight {2}", new Object[] {
items.size(), minWeight, maxWeight });
}
LOGGER.log(Level.FINE, "Sorted {0} Buildable Items with Min Weight {1} and Max Weight {2}", new Object[] { items.size(), minWeight, maxWeight });
}
}

/**
Expand Down

0 comments on commit abc2cc5

Please sign in to comment.