Announcement Announcement Module
Collapse
No announcement yet.
Throw exception after n seconds - like @Timed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Throw exception after n seconds - like @Timed

    Hi, in my business logic i have a method that should be stopped if the execution takes longer then a second.

    Something like this:
    Code:
    // ...
        	public int doCheck(final String condition)
    	{
    		final int result;
    
    		try
    		{
    			result = calculate(condition);
    		}
    		catch (final TimeoutException e)
    		{
    			resut = UNKNOWN;
    		}
    
    		return result;
    	}
    
    	@Timed(1000)
    	private int calculate(final String condition)
    	{
    		// Calculate ... (if it takes longer then 1 sek. a timeoutException should be thrown)
    		
    		return // calulated result.
    	}
    // ...
    For testcases there is the @Timed method. How to implement smth. like tihs?


    Thanks a lot,
    Christian.
Working...
X