huxinqiu opened a new pull request, #4823: URL: https://github.com/apache/hadoop/pull/4823
### Description of PR JIRA - [HADOOP-18429](https://issues.apache.org/jira/browse/HADOOP-18429) The Unit Test get stuck in an infinite loop ```java public void testMutableGaugeFloat() { MutableGaugeFloat mgf = new MutableGaugeFloat(Context,3.2f); assertEquals(3.2f, mgf.value(), 0.0); mgf.incr(); assertEquals(4.2f, mgf.value(), 0.0); } ``` The current implementation converts the value from int to float, causing the compareAndSet method to get stuck. ```java private final boolean compareAndSet(float expect, float update) { return value.compareAndSet(Float.floatToIntBits(expect), Float.floatToIntBits(update)); } private void incr(float delta) { while (true) { float current = value.get(); float next = current + delta; if (compareAndSet(current, next)) { setChanged(); return; } } } ``` Perhaps it could be: ```java private void incr(float delta) { while (true) { float current = Float.intBitsToFloat(value.get()); float next = current + delta; if (compareAndSet(current, next)) { setChanged(); return; } } } ``` ### How was this patch tested? unit test in TestMutableMetrics#testMutableGaugeFloat() -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
