Skip to content

Commit 43d6ec8

Browse files
Remove unnecessary throws IOException in CompressedXContent.string() (#35821)
1 parent e37a0ef commit 43d6ec8

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

server/src/main/java/org/elasticsearch/common/compress/CompressedXContent.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public byte[] uncompressed() {
146146
}
147147
}
148148

149-
public String string() throws IOException {
149+
public String string() {
150150
return new BytesRef(uncompressed()).utf8ToString();
151151
}
152152

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

189189
@Override
190190
public String toString() {
191-
try {
192-
return string();
193-
} catch (IOException e) {
194-
return "_na_";
195-
}
191+
return string();
196192
}
197193
}

server/src/main/java/org/elasticsearch/index/mapper/MapperService.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121

2222
import com.carrotsearch.hppc.ObjectHashSet;
2323
import com.carrotsearch.hppc.cursors.ObjectCursor;
24-
2524
import org.apache.logging.log4j.LogManager;
2625
import org.apache.logging.log4j.message.ParameterizedMessage;
2726
import org.apache.lucene.analysis.Analyzer;
2827
import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
2928
import org.apache.lucene.index.Term;
3029
import org.elasticsearch.Assertions;
31-
import org.elasticsearch.ElasticsearchGenerationException;
3230
import org.elasticsearch.Version;
3331
import org.elasticsearch.cluster.metadata.IndexMetaData;
3432
import org.elasticsearch.cluster.metadata.MappingMetaData;
@@ -336,11 +334,7 @@ private synchronized Map<String, DocumentMapper> internalMerge(Map<String, Compr
336334
} catch (Exception e) {
337335
throw new MapperParsingException("Failed to parse mapping [{}]: {}", e, DEFAULT_MAPPING, e.getMessage());
338336
}
339-
try {
340-
defaultMappingSource = mappings.get(DEFAULT_MAPPING).string();
341-
} catch (IOException e) {
342-
throw new ElasticsearchGenerationException("failed to un-compress", e);
343-
}
337+
defaultMappingSource = mappings.get(DEFAULT_MAPPING).string();
344338
}
345339

346340
final String defaultMappingSourceOrLastStored;

server/src/main/java/org/elasticsearch/indices/IndicesService.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -613,15 +613,11 @@ public IndexShard createShard(ShardRouting shardRouting, RecoveryState recoveryS
613613
(type, mapping) -> {
614614
assert recoveryState.getRecoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS:
615615
"mapping update consumer only required by local shards recovery";
616-
try {
617-
client.admin().indices().preparePutMapping()
618-
.setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid
619-
.setType(type)
620-
.setSource(mapping.source().string(), XContentType.JSON)
621-
.get();
622-
} catch (IOException ex) {
623-
throw new ElasticsearchException("failed to stringify mapping source", ex);
624-
}
616+
client.admin().indices().preparePutMapping()
617+
.setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid
618+
.setType(type)
619+
.setSource(mapping.source().string(), XContentType.JSON)
620+
.get();
625621
}, this);
626622
return indexShard;
627623
}

0 commit comments

Comments
 (0)