Author: sannegrinovero
Date: 2008-06-06 07:42:54 -0400 (Fri, 06 Jun 2008)
New Revision: 14749
Modified:
search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java
search/trunk/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java
search/trunk/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java
search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
search/trunk/src/test/org/hibernate/search/test/session/MassIndexTest.java
search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java
Log:
minor improvements by FindBugs (and stop him throwing some false alarms).
Modified: search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java 2008-06-06
10:35:35 UTC (rev 14748)
+++ search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -306,7 +306,7 @@
perDirectoryProviderManipulationLocks = Collections.unmodifiableMap(
perDirectoryProviderManipulationLocks );
}
- private class ReaderData {
+ private static class ReaderData {
public ReaderData(int semaphore, DirectoryProvider provider) {
this.semaphore = semaphore;
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
---
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-06-06
10:35:35 UTC (rev 14748)
+++
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -258,7 +258,7 @@
}
}
- public class DirectoryProviders {
+ public static class DirectoryProviders {
private final IndexShardingStrategy shardingStrategy;
private final DirectoryProvider[] providers;
Modified: search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java 2008-06-06
10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -75,7 +75,7 @@
s = getSessions().openSession();
s.getTransaction().begin();
- Document entity = (Document) s.get( Document.class, new Long( 1 ) );
+ Document entity = (Document) s.get( Document.class, Long.valueOf( 1 ) );
entity.setSummary( "Object/relational mapping with EJB3" );
s.persist( new Document( "Seam in Action", "", "blah blah blah
blah" ) );
s.getTransaction().commit();
Modified: search/trunk/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java 2008-06-06
10:35:35 UTC (rev 14748)
+++
search/trunk/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -2,6 +2,7 @@
package org.hibernate.search.test.jms.master;
import java.io.Serializable;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.jms.ObjectMessage;
@@ -43,9 +44,11 @@
//create an object wo trigggering indexing
Session s = openSession( );
s.getTransaction().begin();
- s.connection().createStatement().executeUpdate(
+ Statement statement = s.connection().createStatement();
+ statement.executeUpdate(
"insert into TShirt_Master(id, logo, size) values( '1', 'JBoss
balls', 'large')"
);
+ statement.close();
TShirt ts = (TShirt) s.get(TShirt.class, 1);
s.getTransaction().commit();
s.close();
Modified:
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2008-06-06
10:35:35 UTC (rev 14748)
+++
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -68,8 +68,8 @@
.currentTimeMillis() - start ) );
}
- protected class Work implements Runnable {
- private SessionFactory sf;
+ protected static class Work implements Runnable {
+ private final SessionFactory sf;
public volatile int count = 0;
public Work(SessionFactory sf) {
@@ -135,7 +135,7 @@
}
}
- protected class ReverseWork implements Runnable {
+ protected static class ReverseWork implements Runnable {
private SessionFactory sf;
public ReverseWork(SessionFactory sf) {
Modified: search/trunk/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java 2008-06-06
10:35:35 UTC (rev 14748)
+++
search/trunk/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -41,7 +41,7 @@
// into the index.
int id = 1;
for(Book b : result) {
- assertEquals("Expected another id", new Integer(id), b.getId());
+ assertEquals( "Expected another id", Integer.valueOf( id ), b.getId() );
id++;
}
@@ -55,7 +55,7 @@
assertEquals( "Wrong number of test results.", 3, result.size() );
id = 3;
for(Book b : result) {
- assertEquals("Expected another id", new Integer(id), b.getId());
+ assertEquals("Expected another id", Integer.valueOf( id ), b.getId());
id--;
}
Modified: search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2008-06-06
10:35:35 UTC (rev 14748)
+++
search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -165,7 +165,7 @@
}
}
- protected class ReverseWork implements Runnable {
+ protected static class ReverseWork implements Runnable {
private SessionFactory sf;
private Random random = new Random();
Modified: search/trunk/src/test/org/hibernate/search/test/session/MassIndexTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/session/MassIndexTest.java 2008-06-06
10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/session/MassIndexTest.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -1,6 +1,7 @@
//$Id$
package org.hibernate.search.test.session;
+import java.sql.Statement;
import java.util.List;
import java.util.Iterator;
@@ -29,8 +30,10 @@
Transaction tx = s.beginTransaction();
int loop = 14;
for (int i = 0; i < loop; i++) {
- s.connection().createStatement().executeUpdate( "insert into Email(id, title,
body, header) values( + "
+ Statement statmt = s.connection().createStatement();
+ statmt.executeUpdate( "insert into Email(id, title, body, header) values( +
"
+ ( i + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the
software', 'nope')" );
+ statmt.close();
}
tx.commit();
s.close();
@@ -83,10 +86,14 @@
s = new FullTextSessionImpl( openSession() );
s.getTransaction().begin();
- s.connection().createStatement().executeUpdate( "update Email set body='Meet
the guys who write the software'" );
+ Statement stmt = s.connection().createStatement();
+ stmt.executeUpdate( "update Email set body='Meet the guys who write the
software'" );
+ stmt.close();
//insert an object never indexed
- s.connection().createStatement().executeUpdate( "insert into Email(id, title,
body, header) values( + "
+ stmt = s.connection().createStatement();
+ stmt.executeUpdate( "insert into Email(id, title, body, header) values( + "
+ ( loop + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the
software', 'nope')" );
+ stmt.close();
s.getTransaction().commit();
s.close();
@@ -109,7 +116,7 @@
s = Search.createFullTextSession( openSession() );
tx = s.beginTransaction();
//object never indexed
- Email email = (Email) s.get( Email.class, new Long( loop + 1 ) );
+ Email email = (Email) s.get( Email.class, Long.valueOf( loop + 1 ) );
s.index( email );
tx.commit();
s.close();
Modified: search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java 2008-06-06
10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java 2008-06-06
11:42:54 UTC (rev 14749)
@@ -67,7 +67,7 @@
.currentTimeMillis() - start ) );
}
- protected class Work implements Runnable {
+ protected static class Work implements Runnable {
private SessionFactory sf;
public volatile int count = 0;
@@ -132,7 +132,7 @@
}
}
- protected class ReverseWork implements Runnable {
+ protected static class ReverseWork implements Runnable {
private SessionFactory sf;
public ReverseWork(SessionFactory sf) {