#vulnerable code 
                                public void messageReceived(ChannelHandlerContext ctx, Message message) {
        String token = message.body;

        User userThatShared = userRegistry.sharedTokenManager.getUserByToken(token);

        if (userThatShared == null) {
            throw new InvalidTokenException("Illegal sharing token. No user with those shared token.", message.id);
        }

        Integer dashId = getSharedDashId(userThatShared.dashShareTokens, token);

        if (dashId == null) {
            throw new InvalidTokenException("Illegal sharing token. User has not token. Could happen only in rare cases.", message.id);
        }

        DashBoard dashBoard = userThatShared.profile.getDashboardById(dashId);

        ctx.writeAndFlush(produce(message.id, message.command, dashBoard.toString()));
    } 
                            #location 18 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public void messageReceived(ChannelHandlerContext ctx, Message message) {
        String token = message.body;

        User userThatShared = userRegistry.sharedTokenManager.getUserByToken(token);

        if (userThatShared == null) {
            throw new InvalidTokenException("Illegal sharing token. No user with those shared token.", message.id);
        }

        Integer dashId = getSharedDashId(userThatShared.dashShareTokens, token);

        if (dashId == null) {
            throw new InvalidTokenException("Illegal sharing token. User has not token. Could happen only in rare cases.", message.id);
        }

        DashBoard dashBoard = userThatShared.profile.getDashboardById(dashId);
        cleanPrivateData(dashBoard);

        ctx.writeAndFlush(produce(message.id, message.command, dashBoard.toString()));
    }