Skip to content

Commit e0329c5

Browse files
committed
Check Tags instanceof check before iterator empty check in Tags.of()
Signed-off-by: Johnny Lim <[email protected]>
1 parent 2ee39cc commit e0329c5

File tree

1 file changed

+4
-1
lines changed
  • micrometer-core/src/main/java/io/micrometer/core/instrument

1 file changed

+4
-1
lines changed

micrometer-core/src/main/java/io/micrometer/core/instrument/Tags.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,15 @@ public static Tags concat(@Nullable Iterable<? extends Tag> tags, @Nullable Stri
221221
* @return a new {@code Tags} instance
222222
*/
223223
public static Tags of(@Nullable Iterable<? extends Tag> tags) {
224-
if (tags == null || tags == EMPTY || !tags.iterator().hasNext()) {
224+
if (tags == null || tags == EMPTY) {
225225
return Tags.empty();
226226
}
227227
else if (tags instanceof Tags) {
228228
return (Tags) tags;
229229
}
230+
else if (!tags.iterator().hasNext()) {
231+
return Tags.empty();
232+
}
230233
else if (tags instanceof Collection) {
231234
Collection<? extends Tag> tagsCollection = (Collection<? extends Tag>) tags;
232235
return new Tags(tagsCollection.toArray(new Tag[0]));

0 commit comments

Comments
 (0)