Skip to content

Commit

Permalink
SOLR-17232: PropertiesOutputStream overrides write(byte[], int, int). (
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-roustant authored Apr 12, 2024
1 parent 7813f0e commit 5856581
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ Other Changes

* SOLR-17217: Simplify verbose MatcherAssert.assertThat usage in tests (hossman)

* SOLR-17232: PropertiesOutputStream is renamed IndexOutputOutputStream and overrides write(byte[], int, int).
(Bruno Roustant)

================== 9.5.0 ==================
New Features
---------------------
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/core/SolrCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@
import org.apache.solr.update.processor.UpdateRequestProcessorChain.ProcessorInfo;
import org.apache.solr.update.processor.UpdateRequestProcessorFactory;
import org.apache.solr.util.IOFunction;
import org.apache.solr.util.IndexOutputOutputStream;
import org.apache.solr.util.NumberUtils;
import org.apache.solr.util.PropertiesInputStream;
import org.apache.solr.util.PropertiesOutputStream;
import org.apache.solr.util.RefCounted;
import org.apache.solr.util.TestInjection;
import org.apache.solr.util.circuitbreaker.CircuitBreaker;
Expand Down Expand Up @@ -1514,7 +1514,7 @@ private static void writeNewIndexProps(Directory dir, String tmpFileName, String
Writer os = null;
try {
IndexOutput out = dir.createOutput(tmpFileName, DirectoryFactory.IOCONTEXT_NO_CACHE);
os = new OutputStreamWriter(new PropertiesOutputStream(out), StandardCharsets.UTF_8);
os = new OutputStreamWriter(new IndexOutputOutputStream(out), StandardCharsets.UTF_8);
p.store(os, IndexFetcher.INDEX_PROPERTIES);
dir.sync(Collections.singleton(tmpFileName));
} catch (Exception e) {
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
import org.apache.solr.security.AllowListUrlChecker;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.util.FileUtils;
import org.apache.solr.util.PropertiesOutputStream;
import org.apache.solr.util.IndexOutputOutputStream;
import org.apache.solr.util.RTimer;
import org.apache.solr.util.RefCounted;
import org.apache.solr.util.TestInjection;
Expand Down Expand Up @@ -985,7 +985,7 @@ private void logReplicationTimeAndConfFiles(
String tmpFileName = REPLICATION_PROPERTIES + "." + System.nanoTime();
final IndexOutput out = dir.createOutput(tmpFileName, DirectoryFactory.IOCONTEXT_NO_CACHE);
try (Writer outFile =
new OutputStreamWriter(new PropertiesOutputStream(out), StandardCharsets.UTF_8)) {
new OutputStreamWriter(new IndexOutputOutputStream(out), StandardCharsets.UTF_8)) {
props.store(outFile, "Replication details");
dir.sync(Collections.singleton(tmpFileName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
import java.io.OutputStream;
import org.apache.lucene.store.IndexOutput;

public class PropertiesOutputStream extends OutputStream {
/** Wraps an {@link IndexOutput} to expose it as an {@link OutputStream}. */
public class IndexOutputOutputStream extends OutputStream {

private IndexOutput out;
private final IndexOutput out;

public PropertiesOutputStream(IndexOutput out) {
public IndexOutputOutputStream(IndexOutput out) {
this.out = out;
}

Expand All @@ -33,9 +34,13 @@ public void write(int b) throws IOException {
out.writeByte((byte) b);
}

@Override
public void write(byte[] b, int off, int len) throws IOException {
out.writeBytes(b, off, len);
}

@Override
public void close() throws IOException {
super.close();
out.close();
}
}

0 comments on commit 5856581

Please sign in to comment.