#vulnerable code 
                                public Object doGenerate(final Class<?> type) {
        if (type == boolean.class || type == Boolean.class) {
            return RANDOM.nextBoolean();
        }

        if (type == int.class || type == Integer.class) {
            return RANDOM.nextInt();
        }

        if (type == BigInteger.class) {
            return BigInteger.valueOf(RANDOM.nextLong());
        }

        if (type == float.class || type == Float.class) {
            return RANDOM.nextFloat();
        }

        if (type == double.class || type == Double.class) {
            return RANDOM.nextDouble();
        }

        if (type == BigDecimal.class) {
            return BigDecimal.valueOf(RANDOM.nextDouble());
        }

        if (type == long.class || type == Long.class) {
            return RANDOM.nextLong();
        }

        if (type == short.class || type == Short.class) {
            return (short) (RANDOM.nextInt(Short.MAX_VALUE + 1) * (RANDOM.nextBoolean() ? 1 : -1));
        }

        if (type == byte.class || type == Byte.class) {
            final byte[] randombyte = new byte[1];
            RANDOM.nextBytes(randombyte);
            return randombyte[0];
        }

        if (type == char.class || type == Character.class) {
            return CHARACTERS[RANDOM.nextInt(CHARACTERS.length)];
        }

        if (type == String.class) {
            String randomString = "";

            /* prevent zero length string lengths */
            for (int count = 0; count < RANDOM.nextInt(MAX_RANDOM_STRING_LENGTH + 1) + 1; count++) {
                randomString += RandomFactory.getRandomValue(Character.class);
            }
            return randomString;
        }

        if (type == Date.class) {
            return new Date(RandomFactory.getRandomValue(Long.class));
        }

        if (type == Calendar.class) {
            final Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(RandomFactory.getRandomValue(Long.class));
            return calendar;
        }

        return null;
    } 
                            #location 55 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public Object doGenerate(final Class<?> type) {
        if (type == boolean.class || type == Boolean.class) {
            return RANDOM.nextBoolean();
        }

        if (type == int.class || type == Integer.class) {
            return RANDOM.nextInt();
        }

        if (type == BigInteger.class) {
            return BigInteger.valueOf(RANDOM.nextLong());
        }

        if (type == float.class || type == Float.class) {
            return RANDOM.nextFloat();
        }

        if (type == double.class || type == Double.class) {
            return RANDOM.nextDouble();
        }

        if (type == BigDecimal.class) {
            return BigDecimal.valueOf(RANDOM.nextDouble());
        }

        if (type == long.class || type == Long.class) {
            return RANDOM.nextLong();
        }

        if (type == short.class || type == Short.class) {
            return (short) (RANDOM.nextInt(Short.MAX_VALUE + 1) * (RANDOM.nextBoolean() ? 1 : -1));
        }

        if (type == byte.class || type == Byte.class) {
            final byte[] randomByte = new byte[1];
            RANDOM.nextBytes(randomByte);
            return randomByte[0];
        }

        if (type == char.class || type == Character.class) {
            return CHARACTERS[RANDOM.nextInt(CHARACTERS.length)];
        }

        if (type == String.class) {
            String randomString = "";

            /* prevent zero length string lengths */
            for (int count = 0; count < RANDOM.nextInt(MAX_RANDOM_STRING_LENGTH + 1) + 1; count++) {
                randomString += RandomFactory.getRandomValue(Character.class);
            }
            return randomString;
        }

        if (type == Date.class) {
            return new Date(RANDOM.nextLong());
        }

        if (type == Calendar.class) {
            final Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(RANDOM.nextLong());
            return calendar;
        }

        return null;
    }