diff options
author | Noel Grandin <noel@peralex.com> | 2014-08-15 16:28:22 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-08-20 11:47:47 +0200 |
commit | 6884ef6317ddc29a713a342fb102e28ebc8fa5cc (patch) | |
tree | e5c6b203f6c58e118f2000bee4c23769b4cc36da | |
parent | 8c9fdc4a963fd55da59a93c979071f53b84fbc24 (diff) |
java: don't catch and then just rethrow an exception
without doing anything else useful
Change-Id: I5803d84d46e0a70e1759f2202e2c2273087f8723
5 files changed, 25 insertions, 58 deletions
diff --git a/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java b/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java index f2d8e4f97a8e..559fbd810f64 100644 --- a/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java +++ b/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java @@ -134,8 +134,6 @@ public class OptionsEventHandler { if (sMethod.equals("external_event") ){ try { return handleExternalEvent(aWindow, aEventObject); - } catch (com.sun.star.uno.RuntimeException re) { - throw re; } catch (com.sun.star.uno.Exception e) { throw new WrappedTargetException(sMethod, this, e); } diff --git a/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java b/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java index 89d08bb23ed1..e51ed23e6970 100644 --- a/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java +++ b/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java @@ -32,6 +32,7 @@ import com.sun.star.io.XTruncate; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.lib.util.ExceptionHelper; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; @@ -109,17 +110,13 @@ public final class OwnEmbeddedObject extends WeakBase XStorage xOwnStorage = xParentStorage.openStorageElement( aEntryName, com.sun.star.embed.ElementModes.READWRITE ); SwitchOwnPersistence( xParentStorage, xOwnStorage, aEntryName ); } - catch( com.sun.star.uno.RuntimeException e ) - { - throw e; - } catch( com.sun.star.io.IOException e ) { throw e; } catch( com.sun.star.uno.Exception e ) { - throw new com.sun.star.io.IOException( "Error while switching object storage!" ); + throw ExceptionHelper.initCause(new com.sun.star.io.IOException( "Error while switching object storage!" ), e); } } } @@ -170,17 +167,13 @@ public final class OwnEmbeddedObject extends WeakBase xStreamComp.dispose(); } - catch( com.sun.star.uno.RuntimeException e ) - { - throw e; - } catch( com.sun.star.io.IOException e ) { throw e; } catch( com.sun.star.uno.Exception e ) { - throw new com.sun.star.io.IOException( "Error while switching object storage!" ); + throw ExceptionHelper.initCause(new com.sun.star.io.IOException( "Error while switching object storage!" ), e); } } @@ -266,17 +259,13 @@ public final class OwnEmbeddedObject extends WeakBase return aResult; } - catch( com.sun.star.uno.RuntimeException e ) - { - throw e; - } catch( com.sun.star.io.IOException e ) { throw e; } catch( com.sun.star.uno.Exception e ) { - throw new com.sun.star.io.IOException( "Error while reading one of object streams!" ); + throw ExceptionHelper.initCause(new com.sun.star.io.IOException( "Error while reading one of object streams!" ), e); } } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java b/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java index c88633b70b74..9c7ff7939b3a 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java @@ -218,38 +218,31 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase { if ( sMethod.equals( sExternalEvent ) ) { - try + String sEvent = AnyConverter.toString( aEventObject ); + if ( sEvent != null ) { - String sEvent = AnyConverter.toString( aEventObject ); - if ( sEvent != null ) + if ( sEvent.equals( sOk ) ) + { + if ( m_aSettings != null ) + m_aSettings.storeConfiguration(); + } + else if ( sEvent.equals( sInitialize ) || sEvent.equals( sBack ) ) { - if ( sEvent.equals( sOk ) ) + if ( sEvent.equals( sInitialize ) ) { - if ( m_aSettings != null ) - m_aSettings.storeConfiguration(); + m_xDialog = UnoRuntime.queryInterface( XDialog.class, xWindow ); + m_xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, m_xDialog ); + m_aSettings = Settings.getSettings( m_xContext ); + m_aSettings.loadConfiguration(); // throw away all the noncommited changes + InitStrings(); } - else if ( sEvent.equals( sInitialize ) || sEvent.equals( sBack ) ) - { - if ( sEvent.equals( sInitialize ) ) - { - m_xDialog = UnoRuntime.queryInterface( XDialog.class, xWindow ); - m_xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, m_xDialog ); - m_aSettings = Settings.getSettings( m_xContext ); - m_aSettings.loadConfiguration(); // throw away all the noncommited changes - InitStrings(); - } - else if ( m_aSettings != null ) - m_aSettings.loadConfiguration(); // throw away all the noncommited changes + else if ( m_aSettings != null ) + m_aSettings.loadConfiguration(); // throw away all the noncommited changes - RefreshView(); - CheckButtonState(); - } + RefreshView(); + CheckButtonState(); } } - catch ( com.sun.star.uno.RuntimeException r ) - { - throw r; - } } else if ( sMethod.equals( sAdd ) ) { diff --git a/testtools/com/sun/star/comp/bridge/TestComponent.java b/testtools/com/sun/star/comp/bridge/TestComponent.java index 9876c18b0b7b..89af4ba101d5 100644 --- a/testtools/com/sun/star/comp/bridge/TestComponent.java +++ b/testtools/com/sun/star/comp/bridge/TestComponent.java @@ -917,16 +917,9 @@ public class TestComponent { public int getRuntimeException() throws com.sun.star.uno.RuntimeException { - try - { - dothrow( new com.sun.star.uno.RuntimeException( - _string, _xInterface ) ); - return 0; // dummy - } - catch (com.sun.star.uno.RuntimeException t) - { - throw t; - } + dothrow( new com.sun.star.uno.RuntimeException( + _string, _xInterface ) ); + return 0; // dummy } public void setRuntimeException(int _runtimeexception) throws com.sun.star.uno.RuntimeException { diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java index db6c9e0e9573..bbf0128b0dee 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java @@ -200,12 +200,6 @@ public class EmbeddedXMLObject extends EmbeddedObject { } } - catch (SAXException se) { - throw se; - } - catch (IOException ioe) { - throw ioe; - } catch (ParserConfigurationException pce) { throw new SAXException(pce); } |