Skip to content

Commit

Permalink
Remove unnecessary throws IOException in CompressedXContent.string() (e…
Browse files Browse the repository at this point in the history
dimitris-athanasiou authored Nov 22, 2018

Verified

This commit was signed with the committer’s verified signature.
broonie Mark Brown
1 parent e37a0ef commit 43d6ec8
Showing 3 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ public byte[] uncompressed() {
}
}

public String string() throws IOException {
public String string() {
return new BytesRef(uncompressed()).utf8ToString();
}

@@ -188,10 +188,6 @@ public int hashCode() {

@Override
public String toString() {
try {
return string();
} catch (IOException e) {
return "_na_";
}
return string();
}
}
Original file line number Diff line number Diff line change
@@ -21,14 +21,12 @@

import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.hppc.cursors.ObjectCursor;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
import org.apache.lucene.index.Term;
import org.elasticsearch.Assertions;
import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
@@ -336,11 +334,7 @@ private synchronized Map<String, DocumentMapper> internalMerge(Map<String, Compr
} catch (Exception e) {
throw new MapperParsingException("Failed to parse mapping [{}]: {}", e, DEFAULT_MAPPING, e.getMessage());
}
try {
defaultMappingSource = mappings.get(DEFAULT_MAPPING).string();
} catch (IOException e) {
throw new ElasticsearchGenerationException("failed to un-compress", e);
}
defaultMappingSource = mappings.get(DEFAULT_MAPPING).string();
}

final String defaultMappingSourceOrLastStored;
Original file line number Diff line number Diff line change
@@ -613,15 +613,11 @@ public IndexShard createShard(ShardRouting shardRouting, RecoveryState recoveryS
(type, mapping) -> {
assert recoveryState.getRecoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS:
"mapping update consumer only required by local shards recovery";
try {
client.admin().indices().preparePutMapping()
.setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid
.setType(type)
.setSource(mapping.source().string(), XContentType.JSON)
.get();
} catch (IOException ex) {
throw new ElasticsearchException("failed to stringify mapping source", ex);
}
client.admin().indices().preparePutMapping()
.setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid
.setType(type)
.setSource(mapping.source().string(), XContentType.JSON)
.get();
}, this);
return indexShard;
}

0 comments on commit 43d6ec8

Please sign in to comment.