Skip to content

Commit 26cc905

Browse files
qudongfangmanolama
authored andcommitted
Bugfix of NoSuchUniqueId exception occurred in DeferredGroup when resolving tags by ids. (#1410)
Signed-off-by: clarsen <[email protected]>
1 parent e4da2c0 commit 26cc905

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/core/Tags.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import com.stumbleupon.async.DeferredGroupException;
23+
import net.opentsdb.utils.Exceptions;
2224
import org.slf4j.Logger;
2325
import org.slf4j.LoggerFactory;
2426

@@ -353,7 +355,7 @@ static String getValue(final TSDB tsdb, final byte[] row,
353355
* Extracts the value ID of the given tag UD name from the given row key.
354356
* @param tsdb The TSDB instance to use for UniqueId lookups.
355357
* @param row The row key in which to search the tag name.
356-
* @param name The name of the tag to search in the row key.
358+
* @param tag_id The name of the tag to search in the row key.
357359
* @return The value ID associated with the given tag ID, or null if this
358360
* tag ID isn't present in this row key.
359361
*/
@@ -404,7 +406,14 @@ static Map<String, String> getTags(final TSDB tsdb,
404406
final byte[] row) throws NoSuchUniqueId {
405407
try {
406408
return getTagsAsync(tsdb, row).joinUninterruptibly();
407-
} catch (RuntimeException e) {
409+
} catch (DeferredGroupException e) {
410+
final Throwable ex = Exceptions.getCause(e);
411+
if (ex instanceof NoSuchUniqueId) {
412+
throw (NoSuchUniqueId)ex;
413+
}
414+
415+
throw new RuntimeException("Should never be here", e);
416+
} catch (RuntimeException e) {
408417
throw e;
409418
} catch (Exception e) {
410419
throw new RuntimeException("Should never be here", e);
@@ -734,6 +743,14 @@ public static HashMap<String, String> resolveIds(final TSDB tsdb,
734743
return resolveIdsAsync(tsdb, tags).joinUninterruptibly();
735744
} catch (NoSuchUniqueId e) {
736745
throw e;
746+
} catch (DeferredGroupException e) {
747+
final Throwable ex = Exceptions.getCause(e);
748+
if (ex instanceof NoSuchUniqueId) {
749+
throw (NoSuchUniqueId)ex;
750+
}
751+
// TODO process e.results()
752+
753+
throw new RuntimeException("Shouldn't be here", e);
737754
} catch (Exception e) {
738755
throw new RuntimeException("Shouldn't be here", e);
739756
}

0 commit comments

Comments
 (0)