Buggy code:
@ InterfaceAudience . LimitedPrivate ( { "YARN" , "MapReduce" } ) @ Unstable public class Resources { private static final Resource NONE = new Resource ( ) { @ Override public int getMemory ( ) { } @ Override public void setMemory ( int memory ) { } @ Override public int getVirtualCores ( ) { } @ Override public void setVirtualCores ( int cores ) { } @ Override public int getGpuMemory ( ) { } @ Override public void setGpuMemory ( int gpuMemory ) { } @ Override public int compareTo ( Resource o ) { } } ; private static final Resource UNBOUNDED = new Resource ( ) { @ Override public int getMemory ( ) { } @ Override public void setMemory ( int memory ) { } @ Override public int getVirtualCores ( ) { } @ Override public void setVirtualCores ( int cores ) { } @ Override public int getGpuMemory ( ) { } @ Override public void setGpuMemory ( int gpuMemory ) { } @ Override public int compareTo ( Resource o ) { } } ; public static Resource createResource ( int memory ) { } public static Resource createResource ( int memory , int gpuMemory ) { } public static Resource createResource ( int memory , int cores , int gpuMemory ) { Resource resource = Records . newRecord ( Resource . class ) ; resource . setMemory ( memory ) ; resource . setVirtualCores ( cores ) ; <START_BUG> resource . setGpuMemory ( memory ) ; <END_BUG> return resource ; } public static Resource none ( ) { } public static Resource unbounded ( ) { } public static Resource clone ( Resource res ) { } public static Resource addTo ( Resource lhs , Resource rhs ) { } public static Resource add ( Resource lhs , Resource rhs ) { } public static Resource subtractFrom ( Resource lhs , Resource rhs ) { } public static Resource subtract ( Resource lhs , Resource rhs ) { } public static Resource negate ( Resource resource ) { } public static Resource multiplyTo ( Resource lhs , double by ) { } public static Resource multiply ( Resource lhs , double by ) { } public static Resource multiplyAndNormalizeUp ( ResourceCalculator calculator , Resource lhs , double by , Resource factor ) { } public static Resource multiplyAndNormalizeDown ( ResourceCalculator calculator , Resource lhs , double by , Resource factor ) { } public static Resource multiplyAndRoundDown ( Resource lhs , double by ) { } public static Resource normalize ( ResourceCalculator calculator , Resource lhs , Resource min , Resource max , Resource increment ) { } public static Resource roundUp ( ResourceCalculator calculator , Resource lhs , Resource factor ) { } public static Resource roundDown ( ResourceCalculator calculator , Resource lhs , Resource factor ) { } public static boolean isInvalidDivisor ( ResourceCalculator resourceCalculator , Resource divisor ) { } public static float ratio ( ResourceCalculator resourceCalculator , Resource lhs , Resource rhs ) { } public static float divide ( ResourceCalculator resourceCalculator , Resource clusterResource , Resource lhs , Resource rhs ) { } public static Resource divideAndCeil ( ResourceCalculator resourceCalculator , Resource lhs , int rhs ) { } public static boolean equals ( Resource lhs , Resource rhs ) { } public static boolean lessThan ( ResourceCalculator resourceCalculator , Resource clusterResource , Resource lhs , Resource rhs ) { } public static boolean lessThanOrEqual ( ResourceCalculator resourceCalculator , Resource clusterResource , Resource lhs , Resource rhs ) { } public static boolean greaterThan ( ResourceCalculator resourceCalculator , Resource clusterResource , Resource lhs , Resource rhs ) { } public static boolean greaterThanOrEqual ( ResourceCalculator resourceCalculator , Resource clusterResource , Resource lhs , Resource rhs ) { } public static Resource min ( ResourceCalculator resourceCalculator , Resource clusterResource , Resource lhs , Resource rhs ) { } public static Resource max ( ResourceCalculator resourceCalculator , Resource clusterResource , Resource lhs , Resource rhs ) { } public static boolean fitsIn ( Resource smaller , Resource bigger ) { } public static Resource componentwiseMin ( Resource lhs , Resource rhs ) { } }

Fix:
resource . setGpuMemory ( gpuMemory ) ;