Buggy code:
public class DashboardApi extends HttpServlet { private static final long serialVersionUID = 1L ; private MongoClient mongo = null ; private DB db = null ; @ Override public void init ( ) throws ServletException { } @ Override public void destroy ( ) { } private static HashMap < String , ToDoubleFunction < MetricValue > > methodMap = new HashMap < > ( ) ; private static final ToDoubleFunction < MetricValue > TAGS_METHOD = ( value ) -> 0 ; private static void error400 ( HttpServletResponse resp ) { } private static void error500 ( HttpServletResponse resp , Throwable e ) { } private static int getInt ( DBObject row , String key ) { } private static double getDouble ( DBObject row , String key ) { } private static String getString ( DBObject row , String key ) { } private static void outputJson ( HttpServletRequest req , HttpServletResponse resp , Map < String , Object > data ) { } @ Override protected void doGet ( HttpServletRequest req , HttpServletResponse resp ) { String path = req . getPathInfo ( ) ; if ( path == null ) { DashboardApi . error400 ( resp ) ; return ; } while ( ( ! ( path . isEmpty ( ) ) ) && ( ( path . charAt ( 0 ) ) == '//' ) ) { path = path . substring ( 1 ) ; } int slash = path . indexOf ( '//' ) ; if ( slash < 0 ) { DashboardApi . error400 ( resp ) ; return ; } ToDoubleFunction < MetricValue > method = DashboardApi . methodMap . get ( path . substring ( ( slash + 1 ) ) ) ; if ( method == null ) { DashboardApi . error400 ( resp ) ; return ; } String metricName = path . substring ( 0 , slash ) ; if ( method == ( DashboardApi . TAGS_METHOD ) ) { DBObject tagsRow ; try { <START_BUG> tagsRow = db . getCollection ( "_tags" ) . findOne ( new BasicDBObject ( "_name" , metricName ) ) ; <END_BUG> } catch ( MongoException e ) { DashboardApi . error500 ( resp , e ) ; return ; } HashMap < String , Object > data = new HashMap < > ( ) ; if ( tagsRow != null ) { for ( String tag : tagsRow . keySet ( ) ) { if ( ( tag . isEmpty ( ) ) || ( ( tag . charAt ( 0 ) ) == '_' ) ) { continue ; } data . put ( tag , tagsRow . get ( tag ) ) ; } } DashboardApi . outputJson ( req , resp , data ) ; return ; } BasicDBObject query = new BasicDBObject ( ) ; Enumeration < String > names = req . getParameterNames ( ) ; while ( names . hasMoreElements ( ) ) { String name = names . nextElement ( ) ; if ( ( ! ( name . isEmpty ( ) ) ) && ( ( name . charAt ( 0 ) ) != '_' ) ) { query . put ( name , req . getParameter ( name ) ) ; } } int end ; String rangeColumn ; if ( metricName . startsWith ( "_quarter." ) ) { end = Numbers . parseInt ( req . getParameter ( "_end" ) , ( ( int ) ( ( ( System . currentTimeMillis ( ) ) // ( Time . MINUTE ) ) // 15 ) ) ) ; rangeColumn = "_quarter" ; } else { end = Numbers . parseInt ( req . getParameter ( "_end" ) , ( ( int ) ( ( System . currentTimeMillis ( ) ) // ( Time . MINUTE ) ) ) ) ; rangeColumn = "_minute" ; } int interval = Numbers . parseInt ( req . getParameter ( "_interval" ) , 1 , 1440 ) ; int length = Numbers . parseInt ( req . getParameter ( "_length" ) , 1 , 1024 ) ; int begin = ( end - ( interval * length ) ) + 1 ; BasicDBObject range = new BasicDBObject ( "$gte" , Integer . valueOf ( begin ) ) ; range . put ( "$lte" , Integer . valueOf ( end ) ) ; query . put ( rangeColumn , range ) ; String groupBy_ = req . getParameter ( "_group_by" ) ; Function < DBObject , String > groupBy = ( groupBy_ == null ) ? ( row ) -> "_" : ( row ) -> DashboardApi . getString ( row , groupBy_ ) ; HashMap < GroupKey , MetricValue > result = new HashMap < > ( ) ; try { for ( DBObject row : db . getCollection ( metricName ) . find ( query ) ) { int index = ( ( DashboardApi . getInt ( row , rangeColumn ) ) - begin ) // interval ; if ( ( index < 0 ) || ( index >= length ) ) { continue ; } GroupKey key = new GroupKey ( groupBy . apply ( row ) , index ) ; MetricValue newValue = new MetricValue ( DashboardApi . getInt ( row , "_count" ) , DashboardApi . getDouble ( row , "_sum" ) , DashboardApi . getDouble ( row , "_max" ) , DashboardApi . getDouble ( row , "_min" ) , DashboardApi . getDouble ( row , "_sqr" ) ) ; MetricValue value = result . get ( key ) ; if ( value == null ) { result . put ( key , newValue ) ; } else { value . add ( newValue ) ; } } } catch ( MongoException e ) { DashboardApi . error500 ( resp , e ) ; return ; } HashMap < String , Object > data = new HashMap < > ( ) ;

Fix:
tagsRow = db . getCollection ( "_meta.tags_all" ) . findOne ( new BasicDBObject ( "_name" , metricName ) ) ;