afs commented on code in PR #3289:
URL: https://github.com/apache/jena/pull/3289#discussion_r2179551524


##########
jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java:
##########
@@ -368,8 +472,8 @@ protected void execDeleteItem(HttpAction action) {
                 // JENA-1481: Really delete files.
                 if ( ( isTDB1 || isTDB2 ) ) {
                     // Delete databases created by the UI, or the admin 
operation, which are
-                    // in predictable, unshared location on disk.
-                    // There may not be any database files, the in-memory case.
+                    // in predictable, unshared locations on disk.
+                    // There may not be any database files, the in-memory 
case. (TDB supports an in-memeory mode.)

Review Comment:
   Done



##########
jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java:
##########
@@ -298,124 +414,146 @@ protected void execDeleteItem(HttpAction action) {
         if ( ! action.getDataAccessPointRegistry().isRegistered(name) )
             ServletOps.errorNotFound("No such dataset registered: "+name);
 
-        boolean committed = false;
-        synchronized(lock) {
-            // Redo check inside transaction.
-            DataAccessPoint ref = 
action.getDataAccessPointRegistry().get(name);
-            if ( ref == null )
-                ServletOps.errorNotFound("No such dataset registered: "+name);
-
-            // Get a reference before removing.
-            DataService dataService = ref.getDataService();
-            // ---- Make it invisible in this running server.
-            action.getDataAccessPointRegistry().remove(name);
-
-            // Find the configuration.
-            String filename = name.startsWith("/") ? name.substring(1) : name;
-            List<String> configurationFiles = 
FusekiWebapp.existingConfigurationFile(filename);
-
-            if ( configurationFiles.isEmpty() ) {
-                // ---- Unmanaged
-                action.log.warn(format("[%d] Can't delete database 
configuration - not a managed database; dataset=%s", action.id, name));
+        boolean succeeded = false;
+
+        synchronized(FusekiWebapp.systemLock) {
+            try {
+                // Redo check inside transaction.
+                DataAccessPoint ref = 
action.getDataAccessPointRegistry().get(name);
+                if ( ref == null )
+                    ServletOps.errorNotFound("No such dataset registered: 
"+name);
+
+                // Get a reference before removing.
+                DataService dataService = ref.getDataService();
+
+                // Remove from the registry - operation dispatch will not find 
it any more.
+                action.getDataAccessPointRegistry().remove(name);
+
+                // Find the configuration.
+                List<String> configurationFiles = 
FusekiWebapp.existingConfigurationFile(name);
+
+                if ( configurationFiles.isEmpty() ) {
+                    // -- Unmanaged
+                    action.log.warn(format("[%d] Can't delete database 
configuration - not a managed database", action.id, name));
 //                ServletOps.errorOccurred(format("Can't delete database - not 
a managed configuration", name));
-                committed = true;
-                ServletOps.success(action);
-                return;
-            }
+                    succeeded = true;
+                    ServletOps.success(action);
+                    return;
+                }
 
-            if  ( configurationFiles.size() > 1 ) {
-                // -- This should not happen.
-                action.log.warn(format("[%d] There are %d configuration files, 
not one.", action.id, configurationFiles.size()));
-                ServletOps.errorOccurred(format("There are %d configuration 
files, not one. Delete not performed; manual clean up of the filesystem 
needed.",
-                                                configurationFiles.size()));
-                return;
-            }
+                if  ( configurationFiles.size() > 1 ) {
+                    // -- This should not happen.
+                    action.log.warn(format("[%d] There are %d configuration 
files, not one.", action.id, configurationFiles.size()));
+                    ServletOps.errorOccurred(format("There are %d 
configuration files, not one. Delete not performed; manual clean up of the 
filesystem needed.",
+                                                    
configurationFiles.size()));
+                    return;
+                }
 
-            // ---- Remove managed database.
-            String cfgPathname = configurationFiles.get(0);
+                // -- Remove managed database.
+                String cfgPathname = configurationFiles.get(0);
 
-            // Delete configuration file.
-            // Once deleted, server restart will not have the database.
-            FileOps.deleteSilent(cfgPathname);
+                // Delete configuration file.
+                // Once deleted, server restart will not have the database.
+                FileOps.deleteSilent(cfgPathname);
 
-            // Delete the database for real only when it is in the server 
"run/databases"
-            // area. Don't delete databases that reside elsewhere. We do 
delete the
-            // configuration file, so the databases will not be associated 
with the server
-            // anymore.
+                // Delete the database for real only if it is in the server
+                // "run/databases" area. Don't delete databases that reside
+                // elsewhere. We have already deleted the configuration file, 
so the
+                // databases will not be associated with the server anymore.
 
-            @SuppressWarnings("removal")
-            boolean isTDB1 = 
org.apache.jena.tdb1.sys.TDBInternal.isTDB1(dataService.getDataset());
-            boolean isTDB2 = 
org.apache.jena.tdb2.sys.TDBInternal.isTDB2(dataService.getDataset());
+                @SuppressWarnings("removal")
+                boolean isTDB1 = 
org.apache.jena.tdb1.sys.TDBInternal.isTDB1(dataService.getDataset());
+                boolean isTDB2 = 
org.apache.jena.tdb2.sys.TDBInternal.isTDB2(dataService.getDataset());
 
-            // This occasionally fails in tests due to outstanding 
transactions.
-            // Unclear what's holding the transaction (maybe another test 
clearing up slowly).
-            try {
-                dataService.shutdown();
-            } catch (/*DBOE*/ Exception ex) { }
-            // JENA-1481: Really delete files.
-            if ( ( isTDB1 || isTDB2 ) ) {
-                // Delete databases created by the UI, or the admin operation, 
which are
-                // in predictable, unshared location on disk.
-                // There may not be any database files, the in-memory case.
-                Path pDatabase = FusekiWebapp.dirDatabases.resolve(filename);
-                if ( Files.exists(pDatabase)) {
-                    try {
-                        if ( Files.isSymbolicLink(pDatabase)) {
-                            action.log.info(format("[%d] Database is a 
symbolic link, not removing files %s", action.id, pDatabase));
-                        } else {
-                            IO.deleteAll(pDatabase);
-                            action.log.info(format("[%d] Deleted database 
files %s", action.id, pDatabase));
+                try {
+                    dataService.shutdown();
+                } catch (JenaException ex) {
+                    return;
+                }
+                // JENA-1481: Really delete files.
+                if ( ( isTDB1 || isTDB2 ) ) {
+                    // Delete databases created by the UI, or the admin 
operation, which are
+                    // in predictable, unshared locations on disk.
+                    // There may not be any database files, the in-memory 
case. (TDB supports an in-memeory mode.)

Review Comment:
   Done - thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@jena.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@jena.apache.org
For additional commands, e-mail: pr-h...@jena.apache.org

Reply via email to