You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2013/03/03 20:51:13 UTC
svn commit: r1452115 -
/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java
Author: erick
Date: Sun Mar 3 19:51:12 2013
New Revision: 1452115
URL: http://svn.apache.org/r1452115
Log:
Part of SOLR-4525. Need to close some file streams in the test case.
Modified:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java?rev=1452115&r1=1452114&r2=1452115&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java Sun Mar 3 19:51:12 2013
@@ -12,7 +12,7 @@ package org.apache.solr.core;
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS F ANY KIND, either express or implied.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@@ -26,7 +26,7 @@ import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.StringReader;
import java.util.Properties;
import java.util.Set;
@@ -39,7 +39,7 @@ public class TestSolrDiscoveryProperties
initCore();
}
- private final File solrHomeDirectory = new File(TEMP_DIR, "org.apache.solr.core.TestSolrProperties" + File.separator + "solrHome");
+ private final File solrHomeDirectory = new File(TEMP_DIR, "org.apache.solr.core.TestSolrDiscoveryProperties" + File.separator + "solrHome");
private void setMeUp() throws Exception {
if (solrHomeDirectory.exists()) {
@@ -57,7 +57,9 @@ public class TestSolrDiscoveryProperties
String[] parts = extra.split("=");
props.put(parts[0], parts[1]);
}
- props.store(new FileOutputStream(solrProps.getAbsolutePath()), null);
+ FileWriter writer = new FileWriter(solrProps.getAbsolutePath());
+ props.store(writer, null);
+ writer.close();
}
private void addSolrXml() throws Exception {
@@ -88,7 +90,11 @@ public class TestSolrDiscoveryProperties
stockProps.getProperty(CoreDescriptor.CORE_NAME) + File.separator + SolrProperties.CORE_PROP_FILE);
File parent = propFile.getParentFile();
assertTrue("Failed to mkdirs for " + parent.getAbsolutePath(), parent.mkdirs());
- stockProps.store(new FileOutputStream(propFile), null);
+
+ FileWriter writer = new FileWriter(propFile);
+ stockProps.store(writer, null);
+ writer.close();
+
addConfFiles(new File(parent, "conf"));
}
Re: svn commit: r1452115 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java
Posted by Erick Erickson <er...@gmail.com>.
Thanks, that'll teach me to pay attention to the Javadocs for
FileOutputStream.....
On Sun, Mar 3, 2013 at 5:04 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> I fixed it.
>
> In addition, not using InputStream/OutputStream would make it
> inconsistent, as SolrProperties.java and the other methods are using
> streams and not charstreams to read/write. So the format would not fit
> otherwise.
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: Uwe Schindler [mailto:uwe@thetaphi.de]
> > Sent: Sunday, March 03, 2013 10:54 PM
> > To: dev@lucene.apache.org
> > Subject: RE: svn commit: r1452115 -
> > /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscove
> > ryProperties.java
> >
> > For properties files, FileWriter is wrong. Properties should always be
> written
> > by OutputStream, as the format is defined to be binary (see javadocs).
> >
> > Uwe
> >
> > -----
> > Uwe Schindler
> > H.-H.-Meier-Allee 63, D-28213 Bremen
> > http://www.thetaphi.de
> > eMail: uwe@thetaphi.de
> >
> > > -----Original Message-----
> > > From: erick@apache.org [mailto:erick@apache.org]
> > > Sent: Sunday, March 03, 2013 8:51 PM
> > > To: commits@lucene.apache.org
> > > Subject: svn commit: r1452115 -
> > > /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDisc
> > > ove
> > > ryProperties.java
> > >
> > > Author: erick
> > > Date: Sun Mar 3 19:51:12 2013
> > > New Revision: 1452115
> > >
> > > URL: http://svn.apache.org/r1452115
> > > Log:
> > > Part of SOLR-4525. Need to close some file streams in the test case.
> > >
> > > Modified:
> > >
> > > lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDisco
> > > ver
> > > yProperties.java
> > >
> > > Modified:
> > > lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDisco
> > > ver
> > > yProperties.java
> > > URL:
> > > http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/a
> > > pa
> > >
> > che/solr/core/TestSolrDiscoveryProperties.java?rev=1452115&r1=1452114&
> > > r
> > > 2=1452115&view=diff
> > >
> > ==========================================================
> > > ====================
> > > ---
> > > lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDisco
> > > ver
> > > yProperties.java (original)
> > > +++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrD
> > > +++ is coveryProperties.java Sun Mar 3 19:51:12 2013
> > > @@ -12,7 +12,7 @@ package org.apache.solr.core;
> > > *
> > > * Unless required by applicable law or agreed to in writing, software
> > > * distributed under the License is distributed on an "AS IS" BASIS,
> > > - * WITHOUT WARRANTIES OR CONDITIONS F ANY KIND, either express or
> > > implied.
> > > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
> > or
> > > implied.
> > > * See the License for the specific language governing permissions and
> > > * limitations under the License.
> > > */
> > > @@ -26,7 +26,7 @@ import org.junit.Test;
> > >
> > > import java.io.File;
> > > import java.io.FileInputStream;
> > > -import java.io.FileOutputStream;
> > > +import java.io.FileWriter;
> > > import java.io.StringReader;
> > > import java.util.Properties;
> > > import java.util.Set;
> > > @@ -39,7 +39,7 @@ public class TestSolrDiscoveryProperties
> > > initCore();
> > > }
> > >
> > > - private final File solrHomeDirectory = new File(TEMP_DIR,
> > > "org.apache.solr.core.TestSolrProperties" + File.separator +
> > > "solrHome");
> > > + private final File solrHomeDirectory = new File(TEMP_DIR,
> > > + "org.apache.solr.core.TestSolrDiscoveryProperties" + File.separator
> > > + + "solrHome");
> > >
> > > private void setMeUp() throws Exception {
> > > if (solrHomeDirectory.exists()) { @@ -57,7 +57,9 @@ public class
> > > TestSolrDiscoveryProperties
> > > String[] parts = extra.split("=");
> > > props.put(parts[0], parts[1]);
> > > }
> > > - props.store(new FileOutputStream(solrProps.getAbsolutePath()),
> null);
> > > + FileWriter writer = new FileWriter(solrProps.getAbsolutePath());
> > > + props.store(writer, null);
> > > + writer.close();
> > > }
> > >
> > > private void addSolrXml() throws Exception { @@ -88,7 +90,11 @@
> > > public class TestSolrDiscoveryProperties
> > > stockProps.getProperty(CoreDescriptor.CORE_NAME) +
> > > File.separator + SolrProperties.CORE_PROP_FILE);
> > > File parent = propFile.getParentFile();
> > > assertTrue("Failed to mkdirs for " + parent.getAbsolutePath(),
> > > parent.mkdirs());
> > > - stockProps.store(new FileOutputStream(propFile), null);
> > > +
> > > + FileWriter writer = new FileWriter(propFile);
> > > + stockProps.store(writer, null);
> > > + writer.close();
> > > +
> > > addConfFiles(new File(parent, "conf"));
> > > }
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional
> > commands, e-mail: dev-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>
RE: svn commit: r1452115 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java
Posted by Uwe Schindler <uw...@thetaphi.de>.
I fixed it.
In addition, not using InputStream/OutputStream would make it inconsistent, as SolrProperties.java and the other methods are using streams and not charstreams to read/write. So the format would not fit otherwise.
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: Uwe Schindler [mailto:uwe@thetaphi.de]
> Sent: Sunday, March 03, 2013 10:54 PM
> To: dev@lucene.apache.org
> Subject: RE: svn commit: r1452115 -
> /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscove
> ryProperties.java
>
> For properties files, FileWriter is wrong. Properties should always be written
> by OutputStream, as the format is defined to be binary (see javadocs).
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: erick@apache.org [mailto:erick@apache.org]
> > Sent: Sunday, March 03, 2013 8:51 PM
> > To: commits@lucene.apache.org
> > Subject: svn commit: r1452115 -
> > /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDisc
> > ove
> > ryProperties.java
> >
> > Author: erick
> > Date: Sun Mar 3 19:51:12 2013
> > New Revision: 1452115
> >
> > URL: http://svn.apache.org/r1452115
> > Log:
> > Part of SOLR-4525. Need to close some file streams in the test case.
> >
> > Modified:
> >
> > lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDisco
> > ver
> > yProperties.java
> >
> > Modified:
> > lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDisco
> > ver
> > yProperties.java
> > URL:
> > http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/a
> > pa
> >
> che/solr/core/TestSolrDiscoveryProperties.java?rev=1452115&r1=1452114&
> > r
> > 2=1452115&view=diff
> >
> ==========================================================
> > ====================
> > ---
> > lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDisco
> > ver
> > yProperties.java (original)
> > +++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrD
> > +++ is coveryProperties.java Sun Mar 3 19:51:12 2013
> > @@ -12,7 +12,7 @@ package org.apache.solr.core;
> > *
> > * Unless required by applicable law or agreed to in writing, software
> > * distributed under the License is distributed on an "AS IS" BASIS,
> > - * WITHOUT WARRANTIES OR CONDITIONS F ANY KIND, either express or
> > implied.
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
> or
> > implied.
> > * See the License for the specific language governing permissions and
> > * limitations under the License.
> > */
> > @@ -26,7 +26,7 @@ import org.junit.Test;
> >
> > import java.io.File;
> > import java.io.FileInputStream;
> > -import java.io.FileOutputStream;
> > +import java.io.FileWriter;
> > import java.io.StringReader;
> > import java.util.Properties;
> > import java.util.Set;
> > @@ -39,7 +39,7 @@ public class TestSolrDiscoveryProperties
> > initCore();
> > }
> >
> > - private final File solrHomeDirectory = new File(TEMP_DIR,
> > "org.apache.solr.core.TestSolrProperties" + File.separator +
> > "solrHome");
> > + private final File solrHomeDirectory = new File(TEMP_DIR,
> > + "org.apache.solr.core.TestSolrDiscoveryProperties" + File.separator
> > + + "solrHome");
> >
> > private void setMeUp() throws Exception {
> > if (solrHomeDirectory.exists()) { @@ -57,7 +57,9 @@ public class
> > TestSolrDiscoveryProperties
> > String[] parts = extra.split("=");
> > props.put(parts[0], parts[1]);
> > }
> > - props.store(new FileOutputStream(solrProps.getAbsolutePath()), null);
> > + FileWriter writer = new FileWriter(solrProps.getAbsolutePath());
> > + props.store(writer, null);
> > + writer.close();
> > }
> >
> > private void addSolrXml() throws Exception { @@ -88,7 +90,11 @@
> > public class TestSolrDiscoveryProperties
> > stockProps.getProperty(CoreDescriptor.CORE_NAME) +
> > File.separator + SolrProperties.CORE_PROP_FILE);
> > File parent = propFile.getParentFile();
> > assertTrue("Failed to mkdirs for " + parent.getAbsolutePath(),
> > parent.mkdirs());
> > - stockProps.store(new FileOutputStream(propFile), null);
> > +
> > + FileWriter writer = new FileWriter(propFile);
> > + stockProps.store(writer, null);
> > + writer.close();
> > +
> > addConfFiles(new File(parent, "conf"));
> > }
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional
> commands, e-mail: dev-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
RE: svn commit: r1452115 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscoveryProperties.java
Posted by Uwe Schindler <uw...@thetaphi.de>.
For properties files, FileWriter is wrong. Properties should always be written by OutputStream, as the format is defined to be binary (see javadocs).
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: erick@apache.org [mailto:erick@apache.org]
> Sent: Sunday, March 03, 2013 8:51 PM
> To: commits@lucene.apache.org
> Subject: svn commit: r1452115 -
> /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscove
> ryProperties.java
>
> Author: erick
> Date: Sun Mar 3 19:51:12 2013
> New Revision: 1452115
>
> URL: http://svn.apache.org/r1452115
> Log:
> Part of SOLR-4525. Need to close some file streams in the test case.
>
> Modified:
>
> lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscover
> yProperties.java
>
> Modified:
> lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscover
> yProperties.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apa
> che/solr/core/TestSolrDiscoveryProperties.java?rev=1452115&r1=1452114&r
> 2=1452115&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDiscover
> yProperties.java (original)
> +++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestSolrDis
> +++ coveryProperties.java Sun Mar 3 19:51:12 2013
> @@ -12,7 +12,7 @@ package org.apache.solr.core;
> *
> * Unless required by applicable law or agreed to in writing, software
> * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS F ANY KIND, either express or
> implied.
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> * See the License for the specific language governing permissions and
> * limitations under the License.
> */
> @@ -26,7 +26,7 @@ import org.junit.Test;
>
> import java.io.File;
> import java.io.FileInputStream;
> -import java.io.FileOutputStream;
> +import java.io.FileWriter;
> import java.io.StringReader;
> import java.util.Properties;
> import java.util.Set;
> @@ -39,7 +39,7 @@ public class TestSolrDiscoveryProperties
> initCore();
> }
>
> - private final File solrHomeDirectory = new File(TEMP_DIR,
> "org.apache.solr.core.TestSolrProperties" + File.separator + "solrHome");
> + private final File solrHomeDirectory = new File(TEMP_DIR,
> + "org.apache.solr.core.TestSolrDiscoveryProperties" + File.separator +
> + "solrHome");
>
> private void setMeUp() throws Exception {
> if (solrHomeDirectory.exists()) {
> @@ -57,7 +57,9 @@ public class TestSolrDiscoveryProperties
> String[] parts = extra.split("=");
> props.put(parts[0], parts[1]);
> }
> - props.store(new FileOutputStream(solrProps.getAbsolutePath()), null);
> + FileWriter writer = new FileWriter(solrProps.getAbsolutePath());
> + props.store(writer, null);
> + writer.close();
> }
>
> private void addSolrXml() throws Exception { @@ -88,7 +90,11 @@ public
> class TestSolrDiscoveryProperties
> stockProps.getProperty(CoreDescriptor.CORE_NAME) + File.separator +
> SolrProperties.CORE_PROP_FILE);
> File parent = propFile.getParentFile();
> assertTrue("Failed to mkdirs for " + parent.getAbsolutePath(),
> parent.mkdirs());
> - stockProps.store(new FileOutputStream(propFile), null);
> +
> + FileWriter writer = new FileWriter(propFile);
> + stockProps.store(writer, null);
> + writer.close();
> +
> addConfFiles(new File(parent, "conf"));
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org