ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/engine/DelayedDatabaseCloser.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/engine/DelayedDatabaseCloser.java
Status
scanned
Type
file
Name
DelayedDatabaseCloser.java
Extension
.java
Programming language
Java
Mime type
text/x-java
File type
Java source, ASCII text
Tag

      
    
Rootfs path

      
    
Size
2318 (2.3 KB)
MD5
613769525b880adfdf00552eb1550855
SHA1
25cb4f1bfc9af68212679da88227cd4f54506797
SHA256
de06759b6a02a7f6cafe71ab5d2a1e6df2e95825f2d49de1cdbc0c79a65ae0d1
SHA512

      
    
SHA1_git
b8c70255df158de3ff357c64b38068995aced79e
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
DelayedDatabaseCloser.java | 2.3 KB |

/* * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.engine; import java.lang.ref.WeakReference; import org.h2.message.Trace; /** * This class is responsible to close a database after the specified delay. A * database closer object only exists if there is no user connected to the * database. */ class DelayedDatabaseCloser extends Thread { private final Trace trace; private volatile WeakReference<Database> databaseRef; private int delayInMillis; DelayedDatabaseCloser(Database db, int delayInMillis) { databaseRef = new WeakReference<>(db); this.delayInMillis = delayInMillis; trace = db.getTrace(Trace.DATABASE); setName("H2 Close Delay " + db.getShortName()); setDaemon(true); start(); } /** * Stop and disable the database closer. This method is called after a session * has been created. */ void reset() { databaseRef = null; } @Override public void run() { while (delayInMillis > 0) { try { int step = 100; Thread.sleep(step); delayInMillis -= step; } catch (Exception e) { // ignore InterruptedException } WeakReference<Database> ref = databaseRef; if (ref == null || ref.get() == null) { return; } } Database database; WeakReference<Database> ref = databaseRef; if (ref != null && (database = ref.get()) != null) { try { database.close(false); } catch (RuntimeException e) { // this can happen when stopping a web application, // if loading classes is no longer allowed // it would throw an IllegalStateException try { trace.error(e, "could not close the database"); // if this was successful, we ignore the exception // otherwise not } catch (Throwable e2) { e.addSuppressed(e2); throw e; } } } } }
Detected license expression
mpl-2.0 AND epl-1.0
Detected license expression (SPDX)
MPL-2.0 AND EPL-1.0
Percentage of license text
4.13
Copyrights
- end_line: 2
  copyright: Copyright 2004-2023 H2 Group. Multiple-Licensed
  start_line: 2
Holders
- holder: H2 Group. Multiple-Licensed
  end_line: 2
  start_line: 2
Authors

      
    
License detections License expression License expression SPDX
mpl_2_0_and_epl_1_0-796bf8d7-f485-3520-923d-e6a4b1ecd2f3 mpl-2.0 AND epl-1.0 MPL-2.0 AND EPL-1.0
URL Start line End line
https://h2database.com/html/license.html 3 3
Package URL License Primary language
pkg:osgi/com.h2database.source@2.2.220