update to 1.0.2, add sonar, fix execption logging for sonar

This commit is contained in:
Jörg Prante 2016-08-30 09:43:15 +02:00
parent 0c90731fbc
commit af0cb88ea6
5 changed files with 23 additions and 8 deletions

View file

@ -1,3 +1,6 @@
plugins {
id "org.sonarqube" version "2.1-rc1"
}
println "Host: " + java.net.InetAddress.getLocalHost() println "Host: " + java.net.InetAddress.getLocalHost()
println "Gradle: " + gradle.gradleVersion + " JVM: " + org.gradle.internal.jvm.Jvm.current() + " Groovy: " + GroovySystem.getVersion() println "Gradle: " + gradle.gradleVersion + " JVM: " + org.gradle.internal.jvm.Jvm.current() + " Groovy: " + GroovySystem.getVersion()

View file

@ -1,3 +1,3 @@
group = org.xbib group = org.xbib
version = 1.0.1 version = 1.0.2
org.gradle.daemon = true org.gradle.daemon = true

View file

@ -43,6 +43,9 @@ import java.nio.charset.CoderResult;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
/** /**
@ -50,6 +53,8 @@ import javax.xml.stream.XMLStreamException;
*/ */
public class AnselCharset extends Charset { public class AnselCharset extends Charset {
private static final Logger logger = Logger.getLogger(AnselCharset.class.getName());
private static final Map<String, AnselCodeTableParser.CharacterSet> characterSetMap; private static final Map<String, AnselCodeTableParser.CharacterSet> characterSetMap;
static { static {
@ -63,7 +68,8 @@ public class AnselCharset extends Charset {
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); // sonar wants logging
logger.log(Level.SEVERE, e.getMessage(), e);
} }
} }
@ -135,7 +141,8 @@ public class AnselCharset extends Charset {
try { try {
w.write(diacritics.toCharArray()); w.write(diacritics.toCharArray());
} catch (IOException e) { } catch (IOException e) {
// dummy // sonar wants logging
logger.log(Level.SEVERE, e.getMessage(), e);
w.flush(); w.flush();
} }
diacritics = new CharArrayWriter(); diacritics = new CharArrayWriter();

View file

@ -37,6 +37,9 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLInputFactory;
@ -49,6 +52,8 @@ import javax.xml.stream.events.XMLEvent;
class AnselCodeTableParser { class AnselCodeTableParser {
private static final Logger logger = Logger.getLogger(AnselCodeTableParser.class.getName());
private final List<CodeTable> codeTables; private final List<CodeTable> codeTables;
private CodeTable codeTable; private CodeTable codeTable;
@ -64,8 +69,8 @@ class AnselCodeTableParser {
try { try {
codeTables = createCodeTables(inputStream); codeTables = createCodeTables(inputStream);
} catch (XMLStreamException e) { } catch (XMLStreamException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
codeTables = null; codeTables = null;
// ignore
} }
this.codeTables = codeTables; this.codeTables = codeTables;
} }

View file

@ -60,7 +60,7 @@ public class BibliographicCharsetProvider extends CharsetProvider {
private final String packagePrefix; private final String packagePrefix;
/** /**
* Constructor must be public. * Constructor must be public bevause of ServiceLoader.
*/ */
public BibliographicCharsetProvider() { public BibliographicCharsetProvider() {
classMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); classMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
@ -148,11 +148,11 @@ public class BibliographicCharsetProvider extends CharsetProvider {
cache.put(charsetName, new SoftReference<>(charset)); cache.put(charsetName, new SoftReference<>(charset));
return charset; return charset;
} catch (ClassNotFoundException e1) { } catch (ClassNotFoundException e1) {
logger.log(Level.WARNING, "Class not found: " + packagePrefix + "." + className); logger.log(Level.WARNING, "Class not found: " + packagePrefix + "." + className, e1);
} catch (IllegalAccessException e2) { } catch (IllegalAccessException e2) {
logger.log(Level.WARNING, "Illegal access: " + packagePrefix + "." + className); logger.log(Level.WARNING, "Illegal access: " + packagePrefix + "." + className, e2);
} catch (InstantiationException e3) { } catch (InstantiationException e3) {
logger.log(Level.WARNING, "Instantiation failed: " + packagePrefix + "." + className); logger.log(Level.WARNING, "Instantiation failed: " + packagePrefix + "." + className, e3);
} }
return null; return null;
} }