[Schmitzm-commits] r2300 - in trunk: schmitzm-adresses/src/main/java/de/schmitzm/adresses schmitzm-core/src/main/java/de/schmitzm/crypt schmitzm-core/src/main/java/de/schmitzm/i18n schmitzm-core/src/main/java/de/schmitzm/lang schmitzm-core/src/main/java/de/schmitzm/lang/tree schmitzm-core/src/main/java/de/schmitzm/swing schmitzm-core/src/main/java/de/schmitzm/versionnumber schmitzm-excelcsv/src/main/java/de/schmitzm/csv schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui schmitzm-excelcsv/src/main/java/de/schmitzm/jxl/export schmitzm-excelcsv/src/test/java/de/schmitzm/csv schmitzm-gt/src/main/java/de/schmitzm/geotools/feature schmitzm-gt/src/main/java/de/schmitzm/geotools/styling

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sun Apr 21 21:30:05 CEST 2013


Author: alfonx
Date: 2013-04-21 21:30:05 +0200 (Sun, 21 Apr 2013)
New Revision: 2300

Modified:
   trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/crypt/HtPasswd.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/i18n/Translation.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/tree/OperationTree.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationEditJPanel.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvUtil.java
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVColumnAllocationPanel.java
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewTable.java
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/jxl/export/AbstractExportDataProvider.java
   trunk/schmitzm-excelcsv/src/test/java/de/schmitzm/csv/CsvTest.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
Log:
ThreadLocalRandom.current() statt new Random() denn Klasse Random ist nicht Thread-Safe und soll m?\195?\182glichst wiederverwendet werden:
=> ThreadLocalRandom aus Java7 stellt automatisch f?\195?\188r jeden Thread ein Random bereit. 
=> f?\195?\188hrt dadurch zu mehr Wiederverwendung von Random() Objekten was gut f?\195?\188r die Zufallszahlen ist.

Modified: trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
===================================================================
--- trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -352,9 +352,10 @@
 			return new String[] { null, null, null, null };
 		}
 
-		// if (warn)
-		// log.debug("Aus '" + origStrasse + "' wurde Strasse='" + strasse + "', HN='" + StringUtils.trimToNull(hn)
-		// + "', Zusatz='" + StringUtils.trimToNull(zusatz) + "', richtig?");
+		if (warn) {
+			// log.debug("Aus '" + origStrasse + "' wurde Strasse='" + strasse + "', HN='" + StringUtils.trimToNull(hn)
+			// + "', Zusatz='" + StringUtils.trimToNull(zusatz) + "', richtig?");
+		}
 
 		strasse = strasse.replace("Dritten Juni", "3. Juni");
 
@@ -501,7 +502,7 @@
 				if (max - min > 100) {
 					log.warn("Hausnummernbereich von " + min + " bis " + max
 							+ " ausgelassen, weil der Bereich zu groß ist.");
-					return Collections.EMPTY_LIST;
+					return Collections.<String> emptyList();
 				}
 
 				for (int i = min; i <= max; i++) {

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/crypt/HtPasswd.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/crypt/HtPasswd.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/crypt/HtPasswd.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -5,8 +5,8 @@
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.Random;
 import java.util.TreeMap;
+import java.util.concurrent.ThreadLocalRandom;
 
 import org.apache.commons.lang.StringUtils;
 
@@ -39,12 +39,12 @@
 	public void setPasswd(String username, String cleartext) throws IOException {
 
 		String salt = StringUtils.leftPad(
-				String.valueOf(new Random().nextInt(99)), 2);
+				String.valueOf(ThreadLocalRandom.current().nextInt(99)), 2);
 
 		String crypted = UnixCrypt.crypt(salt, cleartext);
 		while (crypted.startsWith(" ") || crypted.endsWith(" ")) {
 			salt = StringUtils.leftPad(
-					String.valueOf(new Random().nextInt(99)), 2);
+					String.valueOf(ThreadLocalRandom.current().nextInt(99)), 2);
 			crypted = UnixCrypt.crypt(salt, cleartext);
 		}
 

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/i18n/Translation.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/i18n/Translation.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/i18n/Translation.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -41,9 +41,9 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
-import java.util.Random;
 import java.util.Set;
 import java.util.WeakHashMap;
+import java.util.concurrent.ThreadLocalRandom;
 
 import javax.swing.JComponent;
 
@@ -426,7 +426,7 @@
 	}
 
 	public void fireTranslationChangedEvents(String lang) {
-		ActionEvent ae = new ActionEvent(this, new Random().nextInt(), lang);
+		ActionEvent ae = new ActionEvent(this, ThreadLocalRandom.current().nextInt(), lang);
 
 		final Iterator<ActionListener> iterator = changeListeners.iterator();
 		while (iterator.hasNext()) {

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -2163,14 +2163,6 @@
 	 *            pattern for the console output (if {@code null} a default pattern "%r\t%p\t%c\t%m%n" is used)
 	 */
 	public static void initializeDefaultLogger(Level logLevel, String logPattern) {
-		// Diry-code by Steve:
-		// Reducing the for libraries.. TODO could be
-		// Math.min(loglevel+2,LEVEL.ERROR)
-		// Logger.getLogger("javax.faces").setLevel(Level.WARN);
-		// Logger.getLogger("com.sun.faces").setLevel(Level.WARN);
-		// Logger.getLogger("org.hibernate").setLevel(Level.DEBUG);
-		// Logger.getLogger("net.sf.ehcache.hibernate").setLevel(Level.WARN);
-
 		if (Logger.getRootLogger().getAllAppenders().hasMoreElements())
 			return;
 
@@ -2182,15 +2174,6 @@
 		Appender appender = new ConsoleAppender(appenderLayout, "System.out");
 		Logger.getRootLogger().addAppender(appender);
 		Logger.getRootLogger().setLevel(logLevel);
-
-		// Diry-code by Steve:
-		// Reducing the for libraries.. TODO could be
-		// Math.min(loglevel+2,LEVEL.ERROR)
-		// Logger.getLogger("javax.faces").setLevel(Level.WARN);
-		// Logger.getLogger("com.sun.faces").setLevel(Level.WARN);
-		// Logger.getLogger("org.hibernate").setLevel(Level.DEBUG);
-		// Logger.getLogger("net.sf.ehcache.hibernate").setLevel(Level.WARN);
-
 	}
 
 	/**

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/tree/OperationTree.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/tree/OperationTree.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/tree/OperationTree.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -32,7 +32,7 @@
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
-import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.regex.Pattern;
 
 import org.apache.log4j.Logger;
@@ -617,7 +617,7 @@
     operator = operator.toUpperCase();
 
     if ( operator.equals("RAND") || operator.equals("RANDOM") )
-      return new Random().nextDouble();
+      return ThreadLocalRandom.current().nextDouble();
     if ( operator.equals("NAN") )
       return Double.NaN;
     if ( operator.equals("CURR_MILLIS") )

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -73,6 +73,7 @@
 import java.util.Map;
 import java.util.Random;
 import java.util.StringTokenizer;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.imageio.ImageIO;
@@ -614,7 +615,7 @@
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static void centerFrameOnScreenRandom(Component comp) {
-		Random r = new Random();
+		Random r = ThreadLocalRandom.current();
 		setRelativeFramePosition(comp, 0.5 + (r.nextDouble() * 0.2 - 0.1),
 				0.5 + (r.nextDouble() * 0.2 - 0.1));
 	}

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationEditJPanel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationEditJPanel.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationEditJPanel.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -35,8 +35,8 @@
 import java.awt.event.ActionListener;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Random;
 import java.util.WeakHashMap;
+import java.util.concurrent.ThreadLocalRandom;
 
 import javax.swing.BorderFactory;
 import javax.swing.JLabel;
@@ -218,7 +218,7 @@
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				al.actionPerformed(new ActionEvent(TranslationEditJPanel.this,
-						new Random().nextInt(), ""));
+						ThreadLocalRandom.current().nextInt(), ""));
 			}
 
 		};

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -309,7 +309,7 @@
 
 		} catch (final Exception e) {
 			log.error("/release.properties could not be read from " + clazz.getSimpleName(), e);
-			return Collections.EMPTY_LIST;
+			return Collections.<String>emptyList();
 		}
 
 	}

Modified: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvUtil.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvUtil.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvUtil.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -55,7 +55,6 @@
 import org.supercsv.prefs.CsvPreference;
 import org.supercsv.util.CSVContext;
 
-import de.schmitzm.data.DataUtil;
 import de.schmitzm.io.FileOutputStream;
 import de.schmitzm.lang.LangUtil;
 import de.schmitzm.lang.ResourceProvider;

Modified: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVColumnAllocationPanel.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVColumnAllocationPanel.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVColumnAllocationPanel.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -30,14 +30,12 @@
 package de.schmitzm.csv.gui;
 
 import java.awt.Font;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import javax.swing.JLabel;
 
 import net.miginfocom.swing.MigLayout;
-
 import de.schmitzm.csv.CsvUtil;
 import de.schmitzm.data.Unit;
 import de.schmitzm.data.UnitUtil;

Modified: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewTable.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewTable.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewTable.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -33,13 +33,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Vector;
 
-import org.apache.commons.lang.StringUtils;
 import org.supercsv.cellprocessor.ift.CellProcessor;
 import org.supercsv.io.ICsvMapReader;
 

Modified: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/jxl/export/AbstractExportDataProvider.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/jxl/export/AbstractExportDataProvider.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/jxl/export/AbstractExportDataProvider.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -29,7 +29,6 @@
  */
 package de.schmitzm.jxl.export;
 
-import java.util.List;
 import java.util.Map;
 
 /**

Modified: trunk/schmitzm-excelcsv/src/test/java/de/schmitzm/csv/CsvTest.java
===================================================================
--- trunk/schmitzm-excelcsv/src/test/java/de/schmitzm/csv/CsvTest.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-excelcsv/src/test/java/de/schmitzm/csv/CsvTest.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -32,9 +32,7 @@
 import java.awt.Frame;
 import java.io.InputStream;
 import java.net.URL;
-import java.nio.charset.Charset;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -46,7 +44,6 @@
 import de.schmitzm.csv.gui.CSVColumnAllocationDialog;
 import de.schmitzm.csv.gui.CSVPreviewDialog;
 import de.schmitzm.io.IOUtil;
-import de.schmitzm.swing.ExceptionDialog;
 import de.schmitzm.testing.TestingClass;
 
 /**

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -53,6 +53,7 @@
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.Vector;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -2063,7 +2064,7 @@
 			Boolean forceNewBuilder, String fID, Object... attrValues) {
 
 		if (fID == null)
-			fID = "FID_" + new Random().nextInt();
+			fID = "FID_" + ThreadLocalRandom.current().nextInt();
 
 		if (forceNewBuilder == null)
 			forceNewBuilder = false;
@@ -2122,7 +2123,7 @@
 	 */
 	public static SimpleFeature createFeature(SimpleFeatureType schema,
 			Object... attrValues) {
-		return createFeature(schema, "FID_" + new Random().nextInt(),
+		return createFeature(schema, "FID_" + ThreadLocalRandom.current().nextInt(),
 				attrValues);
 	}
 
@@ -2159,7 +2160,7 @@
 
 			SimpleFeatureBuilder builder = new SimpleFeatureBuilder(schema);
 			sampleFeature = builder.buildFeature("createSampleFeature_"
-					+ new Random().nextInt(), values);
+					+ ThreadLocalRandom.current().nextInt(), values);
 
 		} catch (org.opengis.feature.IllegalAttributeException e) {
 			// Thrown if the SimpleFeatureType does not validate the attributes
@@ -2298,7 +2299,7 @@
 		if (countAll <= 1)
 			return Double.MAX_VALUE;
 
-		final Random rand = new Random();
+		final Random rand =ThreadLocalRandom.current();
 		final double ratio = SAMPLESIZE.doubleValue() / countAll.doubleValue();
 		// final double ratio = countAll > SAMPLESIZE ?
 		// countAll.doubleValue() / SAMPLESIZE.doubleValue() : 1.;
@@ -2850,7 +2851,7 @@
 			if (counter != null)
 				return "COLUMN" + counter;
 			else
-				return "COLUMN" + new Random().nextInt(9999);
+				return "COLUMN" + ThreadLocalRandom.current().nextInt(9999);
 		}
 
 		return clean;

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java	2013-04-18 18:33:33 UTC (rev 2299)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java	2013-04-21 19:30:05 UTC (rev 2300)
@@ -1748,7 +1748,7 @@
 	public static List<ColorMap> getColorMapsFromStyle(Style style) {
 
 		if (style == null)
-			return Collections.EMPTY_LIST;
+			return Collections.<ColorMap>emptyList();
 
 		final List<RasterSymbolizer> rasterSymbolizers = getRasterSymbolizers(style);
 



More information about the Schmitzm-commits mailing list