@@ -216,15 +216,7 @@ public TSStatus createPipePlugin(final CreatePipePluginPlan createPipePluginPlan
216216 final String jarName = pipePluginMeta .getJarName ();
217217
218218 if (createPipePluginPlan .getJarFile () != null ) {
219- try {
220- pipePluginExecutableManager .savePluginToInstallDir (
221- ByteBuffer .wrap (createPipePluginPlan .getJarFile ().getValues ()), pluginName , jarName );
222- computeFromPluginClass (pluginName , className );
223- } catch (final Exception e ) {
224- // We need to rollback if the creation has failed
225- pipePluginExecutableManager .removePluginFileUnderLibRoot (pluginName , jarName );
226- throw e ;
227- }
219+ savePipePluginWithRollback (createPipePluginPlan );
228220 } else {
229221 final String existed = pipePluginMetaKeeper .getPluginNameByJarName (jarName );
230222 if (Objects .nonNull (existed )) {
@@ -256,6 +248,23 @@ public TSStatus createPipePlugin(final CreatePipePluginPlan createPipePluginPlan
256248 }
257249 }
258250
251+ private void savePipePluginWithRollback (final CreatePipePluginPlan createPipePluginPlan )
252+ throws Exception {
253+ final PipePluginMeta pipePluginMeta = createPipePluginPlan .getPipePluginMeta ();
254+ final String pluginName = pipePluginMeta .getPluginName ();
255+ final String className = pipePluginMeta .getClassName ();
256+ final String jarName = pipePluginMeta .getJarName ();
257+ try {
258+ pipePluginExecutableManager .savePluginToInstallDir (
259+ ByteBuffer .wrap (createPipePluginPlan .getJarFile ().getValues ()), pluginName , jarName );
260+ computeFromPluginClass (pluginName , className );
261+ } catch (final Exception e ) {
262+ // We need to rollback if the creation has failed
263+ pipePluginExecutableManager .removePluginFileUnderLibRoot (pluginName , jarName );
264+ throw e ;
265+ }
266+ }
267+
259268 private void computeFromPluginClass (final String pluginName , final String className )
260269 throws Exception {
261270 final String pluginDirPath = pipePluginExecutableManager .getPluginsDirPath (pluginName );
0 commit comments