diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebugService.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebugService.java index ea5d4e2dbb80fc7af994312a22d1188481887edf..b5278971ccd1d1827a98178a1a13ae6b3fff0b3f 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebugService.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebugService.java @@ -102,9 +102,11 @@ public class DebugService implements NoticeListener, EventHander, IDebugService */ public void prepareDebug() throws SQLException { List inputsParams = Arrays.asList(functionVo.oid); - serverConn.getDebugOptPrepareStatement( + try (PreparedStatement ps = serverConn.getDebugOptPrepareStatement( DebugConstants.DebugOpt.START_SESSION, - inputsParams).execute(); + inputsParams)) { + ps.execute(); + } } /** @@ -203,9 +205,11 @@ public class DebugService implements NoticeListener, EventHander, IDebugService * @throws SQLException the exp */ public void debugOff() throws SQLException { - serverConn.getDebugOptPrepareStatement( + try (PreparedStatement ps = serverConn.getDebugOptPrepareStatement( DebugConstants.DebugOpt.DEBUG_OFF, - new ArrayList(1)).execute(); + new ArrayList(1))) { + ps.execute(); + } } /** @@ -349,6 +353,7 @@ public class DebugService implements NoticeListener, EventHander, IDebugService } private List getListVos(DebugConstants.DebugOpt debugOpt, Class clazz) throws SQLException { + validCheckForConnection(); List inputParams = Arrays.asList(sessionVo.clientPort); try (PreparedStatement ps = clientConn.getDebugOptPrepareStatement( debugOpt, inputParams)) { @@ -397,6 +402,7 @@ public class DebugService implements NoticeListener, EventHander, IDebugService positionVo.func = functionVo.oid; } + validCheckForConnection(); List inputParams = Arrays.asList( sessionVo.clientPort, positionVo.func, @@ -677,8 +683,15 @@ public class DebugService implements NoticeListener, EventHander, IDebugService } private void serverExecuteInner(String sql) throws SQLException { + validCheckForConnection(); try (PreparedStatement ps = serverConn.getStatement(sql)) { ps.execute(); } } + + private void validCheckForConnection() throws SQLException { + if (serverConn == null || clientConn == null) { + throw new SQLException("debug connection already disconnect!"); + } + } } diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/StartDebugHandler.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/StartDebugHandler.java index 14ad5dcedd8205fbf1f346740dbea3370d6bc40a..25039542cd15cb3a0c13ab0522ada49c886e332c 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/StartDebugHandler.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/StartDebugHandler.java @@ -29,6 +29,8 @@ import org.opengauss.mppdbide.bl.serverdatacache.DefaultParameter; import org.opengauss.mppdbide.bl.serverdatacache.IDebugObject; import org.opengauss.mppdbide.bl.serverdatacache.ObjectParameter; import org.opengauss.mppdbide.bl.serverdatacache.ObjectParameter.PARAMETERTYPE; +import org.opengauss.mppdbide.debuger.service.DebugService; +import org.opengauss.mppdbide.debuger.service.WrappedDebugService; import org.opengauss.mppdbide.utils.IMessagesConstants; import org.opengauss.mppdbide.utils.exceptions.DatabaseCriticalException; import org.opengauss.mppdbide.utils.exceptions.DatabaseOperationException; @@ -143,7 +145,11 @@ public class StartDebugHandler { .get(debugObject.getOid()); debugParams = getDebugParams(serverParams); } - serviceHelper.getDebugService().begin(debugParams); + WrappedDebugService debugService = serviceHelper.getDebugService(); + if (debugService == null) { + throw new SQLException("you operation too quick, please retry slowly!"); + } + debugService.begin(debugParams); debugUtils.setDebugStart(true); } catch (DatabaseCriticalException exception) { UIDisplayFactoryProvider.getUIDisplayStateIf().handleDBCriticalError(exception, debugObject.getDatabase()); @@ -157,6 +163,12 @@ public class StartDebugHandler { exception); MPPDBIDEDialogs.generateErrorDialog(MessageConfigLoader.getProperty(IMessagesConstants.PLSQL_ERR), MessageConfigLoader.getProperty(IMessagesConstants.UNKNOWN_INTERNAL_ERR), exception); + } catch (Exception allExp) { + MPPDBIDELoggerUtility.error( + "unknown exception occur " + allExp.getMessage(), + allExp); + MPPDBIDEDialogs.generateErrorDialog(MessageConfigLoader.getProperty(IMessagesConstants.PLSQL_ERR), + MessageConfigLoader.getProperty(IMessagesConstants.UNKNOWN_INTERNAL_ERR), allExp); } }