easyforgood / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

using finally in answer #384

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1.  private class TestInbox extends LinkedBlockingQueue implements MessageInbox{
        @Override
        public Object getMessage() {
            Object x;
            try {
                return this.take();
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }finally{
               return null;
                        }
        }
2. doAnswer(new Answer(){
            @Override
            public Object answer(InvocationOnMock invocation) throws InterruptedException{
                Object[] messages = invocation.getArguments();
                Object msg = messages[0];

                testInbox.put(msg);
                System.out.println("item put into inbox");
                return null;
            }
        }).when(msg1).sendMessage(any());
3.

What is the expected output? What do you see instead?

The expected output when testInbox.getMessage() is called should be the 
argument of testInbox.put(). Running the debugger shows prior to getMessage() 
the item inside the queue is correct, but when testInbox.getMessage() was 
called, the returned object is the one inside the finally statement.

What version of the product are you using? On what operating system?
1.9.5. osx 10.7.5

Please provide any additional information below.

Original issue reported on code.google.com by carrier2...@gmail.com on 8 Oct 2012 at 9:23

GoogleCodeExporter commented 8 years ago
I don't quite follow what the problem is. Can you attach a smal test case that 
reproduces the problem?

Original comment by szcze...@gmail.com on 12 Oct 2012 at 7:22

GoogleCodeExporter commented 8 years ago
Hey,

I'll invalidate this issue. Feel free to say there's still something wrong with 
mockito if you don't agree with this invalidation.

Original comment by brice.du...@gmail.com on 27 Nov 2012 at 5:06