Loading...

jmeter-dev@jakarta.apache.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

svn commit: r804399 - in /jakarta/jmeter/trunk/src: components/org/apache/jmeter/assertions/ components/org/apache/jmeter/config/ components/org/apache/jmeter/modifiers/ core/org/apache/jmeter/functions/ core/org/apache/jmeter/threads/ core/org/apache/... sebb Fri Aug 14 16:00:32 2009

Author: sebb
Date: Fri Aug 14 22:37:19 2009
New Revision: 804399

URL: http://svn.apache.org/viewvc?rev=804399&view=rev
Log:
Make ThreadLocal variables type-safe

Modified:
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XMLAssertion.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/Function.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JsseSSLManager.java
    
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/FileWrapper.java
    
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/IterationCounter.java
    
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/XPathWrapper.java
    
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
    
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/RegexpHTMLParser.java
    
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
    
jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java
    
jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
 Fri Aug 14 22:37:19 2009
@@ -97,13 +97,13 @@
             = JMeterUtils.getPropDefault("assertion.equals_diff_delta_end", 
"]]]");
 
     public ResponseAssertion() {
-        setProperty(new CollectionProperty(TEST_STRINGS, new ArrayList()));
+        setProperty(new CollectionProperty(TEST_STRINGS, new 
ArrayList<String>()));
     }
 
     @Override
     public void clear() {
         super.clear();
-        setProperty(new CollectionProperty(TEST_STRINGS, new ArrayList()));
+        setProperty(new CollectionProperty(TEST_STRINGS, new 
ArrayList<String>()));
     }
 
     private void setTestField(String testField) {

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XMLAssertion.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XMLAssertion.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XMLAssertion.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/XMLAssertion.java
 Fri Aug 14 22:37:19 2009
@@ -39,9 +39,9 @@
     private static final char NEW_LINE = '\n'; // $NON-NLS-1$
 
     // one builder for all requests in a thread
-    private static final ThreadLocal myBuilder = new ThreadLocal() {
+    private static final ThreadLocal<SAXBuilder> myBuilder = new 
ThreadLocal<SAXBuilder>() {
         @Override
-        protected Object initialValue() {
+        protected SAXBuilder initialValue() {
             return new SAXBuilder();
         }
     };
@@ -64,7 +64,7 @@
         // the result data
         String resultData = new String(getResultBody(responseData)); // TODO - 
charset?
 
-        SAXBuilder builder = (SAXBuilder) myBuilder.get();
+        SAXBuilder builder = myBuilder.get();
 
         try {
             builder.build(new StringReader(resultData));

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
 Fri Aug 14 22:37:19 2009
@@ -55,12 +55,12 @@
 
     // Used for per-thread/user numbers
     // Cannot be static, as random numbers are not to be shared between 
instances
-    private transient ThreadLocal perThreadRandom = initThreadLocal();
+    private transient ThreadLocal<Random> perThreadRandom = initThreadLocal();
 
-    private ThreadLocal initThreadLocal() {
-        return new ThreadLocal() {
+    private ThreadLocal<Random> initThreadLocal() {
+        return new ThreadLocal<Random>() {
                 @Override
-                protected Object initialValue() {
+                protected Random initialValue() {
                     init();
                     return new Random(getRandomSeedAsLong());
                 }};
@@ -100,7 +100,7 @@
     public void iterationStart(LoopIterationEvent iterEvent) {
         Random randGen=null;
         if (getPerThread()){
-            randGen = (Random) perThreadRandom.get();
+            randGen = perThreadRandom.get();
         } else {
             synchronized(this){
                 if (globalRandom == null){

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/CounterConfig.java
 Fri Aug 14 22:37:19 2009
@@ -54,12 +54,12 @@
     private long globalCounter = Long.MIN_VALUE;
 
     // Used for per-thread/user numbers
-    private transient ThreadLocal perTheadNumber;
+    private transient ThreadLocal<Long> perTheadNumber;
 
     private void init() {
-        perTheadNumber = new ThreadLocal() {
+        perTheadNumber = new ThreadLocal<Long>() {
             @Override
-            protected synchronized Object initialValue() {
+            protected Long initialValue() {
                 return new Long(getStart());
             }
         };
@@ -89,7 +89,7 @@
             variables.put(getVarName(), formatNumber(globalCounter));
             globalCounter += increment;
         } else {
-            long current = ((Long) perTheadNumber.get()).longValue();
+            long current = perTheadNumber.get().longValue();
             variables.put(getVarName(), formatNumber(current));
             current += increment;
             if (current > end) {

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/Function.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/Function.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/Function.java 
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/functions/Function.java Fri 
Aug 14 22:37:19 2009
@@ -65,5 +65,5 @@
      * least return a List containing the correct number of blank strings, one
      * for each argument.
      */
-    public List getArgumentDesc();
+    public List<String> getArgumentDesc();
 }

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java
 (original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java
 Fri Aug 14 22:37:19 2009
@@ -25,9 +25,9 @@
  * Keeps track of active and total thread counts.
  */
 public final class JMeterContextService {
-    private static final ThreadLocal threadContext = new ThreadLocal() {
+    private static final ThreadLocal<JMeterContext> threadContext = new 
ThreadLocal<JMeterContext>() {
         @Override
-        public Object initialValue() {
+        public JMeterContext initialValue() {
             return new JMeterContext();
         }
     };
@@ -53,7 +53,7 @@
      * @return the current thread Context
      */
     public static JMeterContext getContext() {
-        return (JMeterContext) threadContext.get();
+        return threadContext.get();
     }
 
     /**

Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java 
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JMeterUtils.java Fri 
Aug 14 22:37:19 2009
@@ -76,7 +76,7 @@
 
     private static volatile Properties appProperties;
 
-    private static final Vector localeChangeListeners = new Vector();
+    private static final Vector<LocaleChangeListener> localeChangeListeners = 
new Vector<LocaleChangeListener>();
 
     private static volatile Locale locale;
 
@@ -93,9 +93,9 @@
     
     private static volatile boolean ignoreResorces = false; // Special flag 
for use in debugging resources
 
-    private static final ThreadLocal localMatcher = new ThreadLocal() {
+    private static final ThreadLocal<Perl5Matcher> localMatcher = new 
ThreadLocal<Perl5Matcher>() {
         @Override
-        protected Object initialValue() {
+        protected Perl5Matcher initialValue() {
             return new Perl5Matcher();
         }
     };
@@ -107,7 +107,7 @@
      * Gets Perl5Matcher for this thread.
      */
     public static Perl5Matcher getMatcher() {
-        return (Perl5Matcher) localMatcher.get();
+        return localMatcher.get();
     }
 
     /**
@@ -570,8 +570,8 @@
     // TODO - does not appear to be called directly
     public static Vector getControllers(Properties properties) {
         String name = "controller."; // $NON-NLS-1$
-        Vector v = new Vector();
-        Enumeration names = properties.keys();
+        Vector<Object> v = new Vector<Object>();
+        Enumeration<?> names = properties.keys();
         while (names.hasMoreElements()) {
             String prop = (String) names.nextElement();
             if (prop.startsWith(name)) {
@@ -816,9 +816,9 @@
         }
 
         try {
-            Class c = Class.forName(impls);
+            Class<?> c = Class.forName(impls);
             try {
-                Class o = Class.forName(className);
+                Class<?> o = Class.forName(className);
                 Object res = o.newInstance();
                 if (c.isInstance(res)) {
                     return res;
@@ -851,7 +851,7 @@
     public static Vector instantiate(Vector v, String className) {
         Vector i = new Vector();
         try {
-            Class c = Class.forName(className);
+            Class<?> c = Class.forName(className);
             Enumeration elements = v.elements();
             while (elements.hasMoreElements()) {
                 String name = (String) elements.nextElement();

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JsseSSLManager.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JsseSSLManager.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JsseSSLManager.java 
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JsseSSLManager.java 
Fri Aug 14 22:37:19 2009
@@ -89,7 +89,7 @@
     private Provider pro = null;
 
     private SSLContext defaultContext; // If we are using a single session
-    private ThreadLocal threadlocal; // Otherwise
+    private ThreadLocal<SSLContext> threadlocal; // Otherwise
 
     /**
      * Create the SSLContext, and wrap all the X509KeyManagers with
@@ -109,7 +109,7 @@
                 log.debug("Creating shared context");
                 this.defaultContext = createContext();
             } else {
-                this.threadlocal = new ThreadLocal();
+                this.threadlocal = new ThreadLocal<SSLContext>();
             }
 
             /*
@@ -190,7 +190,7 @@
             return this.defaultContext;
         }
 
-        SSLContext sslContext = (SSLContext) this.threadlocal.get();
+        SSLContext sslContext = this.threadlocal.get();
         if (sslContext == null) {
             if (log.isDebugEnabled()){
                 log.debug("Creating threadLocal SSL context for: 
"+Thread.currentThread().getName());

Modified: 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/FileWrapper.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/FileWrapper.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/FileWrapper.java 
(original)
+++ 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/FileWrapper.java 
Fri Aug 14 22:37:19 2009
@@ -52,7 +52,8 @@
      * - maps file names to  containers
      * - ensures only one container per file across all threads
      */
-    private static final Map fileContainers = new HashMap();
+    private static final Map<String, FileRowColContainer> fileContainers =
+        new HashMap<String, FileRowColContainer>();
 
     /*
      * Only needed locally
@@ -64,10 +65,11 @@
     }
 
     /* The cache of file packs - used to improve thread access */
-    private static final ThreadLocal filePacks = new ThreadLocal() {
+    private static final ThreadLocal<Map<String, FileWrapper>> filePacks = 
+        new ThreadLocal<Map<String, FileWrapper>>() {
         @Override
-        protected Object initialValue() {
-            return new HashMap();
+        protected Map<String, FileWrapper> initialValue() {
+            return new HashMap<String, FileWrapper>();
         }
     };
 
@@ -93,7 +95,7 @@
             log.error("Alias cannot be empty");
             return;
         }
-        Map m = (Map) filePacks.get();
+        Map<String, FileWrapper> m = filePacks.get();
         if (m.get(alias) == null) {
             FileRowColContainer frcc;
             try {
@@ -110,7 +112,7 @@
 
     private static FileRowColContainer getFile(String file, String alias) 
throws FileNotFoundException, IOException {
         FileRowColContainer frcc;
-        if ((frcc = (FileRowColContainer) fileContainers.get(alias)) == null) {
+        if ((frcc = fileContainers.get(alias)) == null) {
             frcc = new FileRowColContainer(file);
             fileContainers.put(alias, frcc);
             log.info("Saved " + file + " as " + alias + " delimiter=<" + 
frcc.getDelimiter() + ">");
@@ -128,8 +130,8 @@
      */
     public static void endRow(String file) {
         file = checkDefault(file);
-        Map my = (Map) filePacks.get();
-        FileWrapper fw = (FileWrapper) (my).get(file);
+        Map<String, FileWrapper> my = filePacks.get();
+        FileWrapper fw = my.get(file);
         if (fw == null) {
             log.warn("endRow(): no entry for " + file);
         } else {
@@ -145,8 +147,8 @@
     }
 
     public static String getColumn(String file, int col) {
-        Map my = (Map) filePacks.get();
-        FileWrapper fw = (FileWrapper) (my).get(file);
+        Map<String, FileWrapper> my = filePacks.get();
+        FileWrapper fw = my.get(file);
         if (fw == null) // First call
         {
             if (file.startsWith("*")) { //$NON-NLS-1$
@@ -155,7 +157,7 @@
                 file = checkDefault(file);
                 log.info("Attaching " + file);
                 open(file, file);
-                fw = (FileWrapper) my.get(file);
+                fw = my.get(file);
             }
             // TODO improve the error handling
             if (fw == null) {
@@ -181,8 +183,8 @@
      */
     public static int getCurrentRow(String file) {
 
-        Map my = (Map) filePacks.get();
-        FileWrapper fw = (FileWrapper) (my).get(file);
+        Map<String, FileWrapper> my = filePacks.get();
+        FileWrapper fw = my.get(file);
         if (fw == null) // Not yet open
         {
             return -1;
@@ -195,9 +197,9 @@
      */
     public static void clearAll() {
         log.debug("clearAll()");
-        Map my = (Map) filePacks.get();
-        for (Iterator i = my.entrySet().iterator(); i.hasNext();) {
-            Object fw = i.next();
+        Map<String, FileWrapper> my = filePacks.get();
+        for (Iterator<Map.Entry<String, FileWrapper>>  i = 
my.entrySet().iterator(); i.hasNext();) {
+            Map.Entry<String, FileWrapper> fw = i.next();
             log.info("Removing " + fw.toString());
             i.remove();
         }

Modified: 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/IterationCounter.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/IterationCounter.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/IterationCounter.java
 (original)
+++ 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/IterationCounter.java
 Fri Aug 14 22:37:19 2009
@@ -30,11 +30,11 @@
 
 public class IterationCounter extends AbstractFunction {
 
-    private static final List desc = new LinkedList();
+    private static final List<String> desc = new LinkedList<String>();
 
     private static final String KEY = "__counter"; //$NON-NLS-1$
 
-    private ThreadLocal perThreadInt;
+    private ThreadLocal<Integer> perThreadInt;
 
     private Object[] variables;
 
@@ -44,9 +44,9 @@
        synchronized(this){
            globalCounter=0;
        }
-       perThreadInt = new ThreadLocal(){
+       perThreadInt = new ThreadLocal<Integer>(){
             @Override
-            protected synchronized Object initialValue() {
+            protected Integer initialValue() {
                 return new Integer(0);
             }
         };
@@ -86,7 +86,7 @@
 
         if (perThread) {
             int threadCounter;
-            threadCounter = ((Integer) perThreadInt.get()).intValue() + 1;
+            threadCounter = perThreadInt.get().intValue() + 1;
             perThreadInt.set(new Integer(threadCounter));
             counterString = String.valueOf(threadCounter);
         } else {
@@ -126,7 +126,7 @@
      *
      * @see org.apache.jmeter.functions.Function#getArgumentDesc()
      */
-    public List getArgumentDesc() {
+    public List<String> getArgumentDesc() {
         return desc;
     }
 }

Modified: 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/XPathWrapper.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/XPathWrapper.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/XPathWrapper.java
 (original)
+++ 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/XPathWrapper.java
 Fri Aug 14 22:37:19 2009
@@ -47,14 +47,15 @@
      * The key is the concatenation of the file name and the XPath string
      */
     //@GuardedBy("fileContainers")
-    private static final Map/*<String, XPathFileContainer>*/ fileContainers =
-        new HashMap/*<String, XPathFileContainer>*/();
+    private static final Map<String, XPathFileContainer> fileContainers =
+        new HashMap<String, XPathFileContainer>();
 
     /* The cache of file packs - for faster local access */
-    private static final ThreadLocal filePacks = new ThreadLocal() {
+    private static final ThreadLocal<Map<String, XPathFileContainer>> 
filePacks =
+        new ThreadLocal<Map<String, XPathFileContainer>>() {
         @Override
-        protected Object initialValue() {
-            return new HashMap();
+        protected Map<String, XPathFileContainer> initialValue() {
+            return new HashMap<String, XPathFileContainer>();
         }
     };
 
@@ -90,13 +91,13 @@
      * @return the next row from the file container
      */
     public static String getXPathString(String file, String xpathString) {
-        Map my = (Map) filePacks.get();
+        Map<String, XPathFileContainer> my = filePacks.get();
         String key = file+xpathString;
-        XPathFileContainer xpfc = (XPathFileContainer) my.get(key);
+        XPathFileContainer xpfc = my.get(key);
         if (xpfc == null) // We don't have a local copy
         {
             synchronized(fileContainers){
-                xpfc = (XPathFileContainer) fileContainers.get(key);
+                xpfc = fileContainers.get(key);
                 if (xpfc == null) { // There's no global copy either
                     xpfc=open(file, xpathString);
                 }
@@ -122,8 +123,7 @@
 
     public static void clearAll() {
         log.debug("clearAll()");
-        Map my = (Map) filePacks.get();
-        my.clear();
+        filePacks.get().clear();
         String tname = Thread.currentThread().getName();
         log.info(tname+": clearing container");
         synchronized (fileContainers) {

Modified: 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
 Fri Aug 14 22:37:19 2009
@@ -50,7 +50,7 @@
 
     public static final String CLEAR = "clearEachIteration"; // $NON-NLS-1$
 
-    private transient ThreadLocal threadCache;
+    private transient ThreadLocal<Map<String, CacheEntry>> threadCache;
 
     public CacheManager() {
         setProperty(new BooleanProperty(CLEAR, false));
@@ -142,7 +142,7 @@
      * @param method where to set the headers
      */
     public void setHeaders(URL url, HttpMethod method) {
-        CacheEntry entry = (CacheEntry) getCache().get(url.toString());
+        CacheEntry entry = getCache().get(url.toString());
         if (log.isDebugEnabled()){
             log.debug(method.getName()+"(OAHC) "+url.toString()+" "+entry);
         }
@@ -166,7 +166,7 @@
      * @param conn where to set the headers
      */
     public void setHeaders(HttpURLConnection conn, URL url) {
-        CacheEntry entry = (CacheEntry) getCache().get(url.toString());
+        CacheEntry entry = getCache().get(url.toString());
         if (log.isDebugEnabled()){
             log.debug(conn.getRequestMethod()+"(Java) "+url.toString()+" 
"+entry);
         }
@@ -182,8 +182,8 @@
         }
     }
 
-    private Map getCache(){
-        return (Map) threadCache.get();
+    private Map<String, CacheEntry> getCache(){
+        return threadCache.get();
     }
 
     public boolean getClearEachIteration() {
@@ -202,10 +202,10 @@
 
     private void clearCache() {
         log.debug("Clear cache");
-        threadCache = new ThreadLocal(){
+        threadCache = new ThreadLocal<Map<String, CacheEntry>>(){
             @Override
-            protected Object initialValue(){
-                return new HashMap();
+            protected Map<String, CacheEntry> initialValue(){
+                return new HashMap<String, CacheEntry>();
             }
         };
     }

Modified: 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/RegexpHTMLParser.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/RegexpHTMLParser.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/RegexpHTMLParser.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/RegexpHTMLParser.java
 Fri Aug 14 22:37:19 2009
@@ -115,9 +115,10 @@
     /**
      * Thread-local input:
      */
-    private static final ThreadLocal localInput = new ThreadLocal() {
+    private static final ThreadLocal<PatternMatcherInput> localInput =
+        new ThreadLocal<PatternMatcherInput>() {
         @Override
-        protected Object initialValue() {
+        protected PatternMatcherInput initialValue() {
             return new PatternMatcherInput(new char[0]);
         }
     };
@@ -144,7 +145,7 @@
     public Iterator getEmbeddedResourceURLs(byte[] html, URL baseUrl, 
URLCollection urls) {
 
         Perl5Matcher matcher = JMeterUtils.getMatcher();
-        PatternMatcherInput input = (PatternMatcherInput) localInput.get();
+        PatternMatcherInput input = localInput.get();
         // TODO: find a way to avoid the cost of creating a String here --
         // probably a new PatternMatcherInput working on a byte[] would do
         // better.

Modified: 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
 Fri Aug 14 22:37:19 2009
@@ -60,6 +60,7 @@
 import org.apache.commons.httpclient.methods.multipart.FilePart;
 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
 import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.PartBase;
 import org.apache.commons.httpclient.methods.multipart.StringPart;
 import org.apache.commons.httpclient.params.DefaultHttpParams;
 import org.apache.commons.httpclient.params.HttpMethodParams;
@@ -126,10 +127,11 @@
     /*
      * Connection is re-used within the thread if possible
      */
-    static final ThreadLocal httpClients = new ThreadLocal();
+    static final ThreadLocal<Map<HostConfiguration, HttpClient>> httpClients =
+        new ThreadLocal<Map<HostConfiguration, HttpClient>>();
 
-    private static final Set nonProxyHostFull   = new HashSet();// 
www.apache.org
-    private static final List nonProxyHostSuffix = new ArrayList();// 
.apache.org
+    private static final Set<String> nonProxyHostFull   = new 
HashSet<String>();// www.apache.org
+    private static final List<String> nonProxyHostSuffix = new 
ArrayList<String>();// .apache.org
 
     private static final int nonProxyHostSuffixSize;
 
@@ -141,7 +143,7 @@
 
     private static boolean isPartialMatch(String host) {
         for (int i=0;i<nonProxyHostSuffixSize;i++){
-            if (host.endsWith((String)nonProxyHostSuffix.get(i))) {
+            if (host.endsWith(nonProxyHostSuffix.get(i))) {
                 return true;
             }
         }
@@ -271,7 +273,7 @@
             }
 
             // We don't know how many entries will be skipped
-            ArrayList partlist = new ArrayList();
+            ArrayList<PartBase> partlist = new ArrayList<PartBase>();
             // Create the parts
             // Add any parameters
             PropertyIterator args = getArguments().iterator();
@@ -296,7 +298,7 @@
 
             // Set the multipart for the post
             int partNo = partlist.size();
-            Part[] parts = (Part[])partlist.toArray(new Part[partNo]);
+            Part[] parts = partlist.toArray(new Part[partNo]);
             MultipartRequestEntity multiPart = new 
MultipartRequestEntity(parts, post.getParams());
             post.setRequestEntity(multiPart);
 
@@ -544,8 +546,8 @@
             hc.setProxy(PROXY_HOST, PROXY_PORT);
         }
 
-        Map map = (Map) httpClients.get();
-        HttpClient httpClient = (HttpClient) map.get(hc);
+        Map<HostConfiguration, HttpClient> map = httpClients.get();
+        HttpClient httpClient = map.get(hc);
 
         if ( httpClient == null )
         {
@@ -1088,7 +1090,7 @@
         log.debug("Thread Started");
 
         // Does not need to be synchronised, as all access is from same thread
-        httpClients.set ( new HashMap() );
+        httpClients.set ( new HashMap<HostConfiguration, HttpClient>() );
     }
 
     @Override
@@ -1096,13 +1098,13 @@
         log.debug("Thread Finished");
 
         // Does not need to be synchronised, as all access is from same thread
-        Map map = (Map)httpClients.get();
+        Map<HostConfiguration, HttpClient> map = httpClients.get();
 
         if ( map != null ) {
-            for ( Iterator it = map.entrySet().iterator(); it.hasNext(); )
+            for ( Iterator<Map.Entry<HostConfiguration, HttpClient> > it = 
map.entrySet().iterator(); it.hasNext(); )
             {
-                Map.Entry entry = (Map.Entry) it.next();
-                HttpClient cl = (HttpClient) entry.getValue();
+                Map.Entry<HostConfiguration, HttpClient> entry = it.next();
+                HttpClient cl = entry.getValue();
                 // Can cause NPE in HttpClient 3.1
                 
//((SimpleHttpConnectionManager)cl.getHttpConnectionManager()).shutdown();// 
Closes the connection
                 // Revert to original method:

Modified: 
jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java
 Fri Aug 14 22:37:19 2009
@@ -62,7 +62,7 @@
     private transient ResourceLimitingJdbcDataSource excaliburSource;
 
     // Keep a record of the pre-thread pools so that they can be disposed of 
at the end of a test
-    private transient Set perThreadPoolSet;
+    private transient Set<ResourceLimitingJdbcDataSource> perThreadPoolSet;
 
     public DataSourceElement() {
     }
@@ -75,9 +75,9 @@
             excaliburSource = null;
         }
         if (perThreadPoolSet != null) {// in case
-            Iterator it = perThreadPoolSet.iterator();
+            Iterator<ResourceLimitingJdbcDataSource> it = 
perThreadPoolSet.iterator();
             while(it.hasNext()){
-                ResourceLimitingJdbcDataSource dsc = 
(ResourceLimitingJdbcDataSource)it.next();
+                ResourceLimitingJdbcDataSource dsc = it.next();
                 log.debug("Disposing pool: "+dsc.getInstrumentableName()+" 
@"+System.identityHashCode(dsc));
                 dsc.dispose();
             }
@@ -101,7 +101,7 @@
             log.error("JDBC data source already defined for: "+poolName);
         } else {
             String maxPool = getPoolMax();
-            perThreadPoolSet = Collections.synchronizedSet(new HashSet());
+            perThreadPoolSet = Collections.synchronizedSet(new 
HashSet<ResourceLimitingJdbcDataSource>());
             if (maxPool.equals("0")){ // i.e. if we want per thread pooling
                 variables.putObject(poolName, new DataSourceComponentImpl()); 
// pool will be created later
             } else {
@@ -229,10 +229,11 @@
     }
 
     // used to hold per-thread singleton connection pools
-    private static final ThreadLocal perThreadPoolMap = new ThreadLocal(){
+    private static final ThreadLocal<Map<String, 
ResourceLimitingJdbcDataSource>> perThreadPoolMap =
+        new ThreadLocal<Map<String, ResourceLimitingJdbcDataSource>>(){
         @Override
-        protected synchronized Object initialValue() {
-            return new HashMap();
+        protected Map<String, ResourceLimitingJdbcDataSource> initialValue() {
+            return new HashMap<String, ResourceLimitingJdbcDataSource>();
         }
     };
 
@@ -259,8 +260,8 @@
             if (sharedDSC != null){ // i.e. shared pool
                 dsc = sharedDSC;
             } else {
-                Map poolMap = (Map) perThreadPoolMap.get();
-                dsc = (ResourceLimitingJdbcDataSource) 
poolMap.get(getDataSource());
+                Map<String, ResourceLimitingJdbcDataSource> poolMap = (Map) 
perThreadPoolMap.get();
+                dsc = poolMap.get(getDataSource());
                 if (dsc == null){
                     dsc = initPool("1");
                     poolMap.put(getDataSource(),dsc);

Modified: 
jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java?rev=804399&r1=804398&r2=804399&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
 Fri Aug 14 22:37:19 2009
@@ -112,10 +112,12 @@
     }
 
     /** the cache of TCP Connections */
-    private static final ThreadLocal tp = new ThreadLocal() {
+    // KEY = TCPKEY or ERRKEY, Entry= Socket or String
+    private static final ThreadLocal<Map<String, Object>> tp =
+        new ThreadLocal<Map<String, Object>>() {
         @Override
-        protected Object initialValue() {
-            return new HashMap();
+        protected Map<String, Object> initialValue() {
+            return new HashMap<String, Object>();
         }
     };
 
@@ -126,12 +128,12 @@
     }
 
     private String getError() {
-        Map cp = (Map) tp.get();
+        Map<String, Object> cp = tp.get();
         return (String) cp.get(ERRKEY);
     }
 
     private Socket getSocket() {
-        Map cp = (Map) tp.get();
+        Map<String, Object> cp = tp.get();
         Socket con = null;
         if (isReUseConnection()) {
             con = (Socket) cp.get(TCPKEY);
@@ -250,7 +252,7 @@
     private static final String protoPrefix = 
"org.apache.jmeter.protocol.tcp.sampler."; //$NON-NLS-1$
 
     private Class getClass(String className) {
-        Class c = null;
+        Class<?> c = null;
         try {
             c = Class.forName(className, false, 
Thread.currentThread().getContextClassLoader());
         } catch (ClassNotFoundException e) {
@@ -266,7 +268,7 @@
 
     private TCPClient getProtocol() {
         TCPClient TCPClient = null;
-        Class javaClass = getClass(getClassname());
+        Class<?> javaClass = getClass(getClassname());
         if (javaClass == null){
             return null;
         }
@@ -375,7 +377,7 @@
 }
 
     private void closeSocket() {
-        Map cp = (Map) tp.get();
+        Map<String, Object> cp = tp.get();
         Socket con = (Socket) cp.remove(TCPKEY);
         if (con != null) {
             log.debug(this + " Closing connection " + con); //$NON-NLS-1$



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]