ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/util/CloseWatcher.java

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

      
    
Rootfs path

      
    
Size
3333 (3.3 KB)
MD5
5c8997b20a1075d51d9a7fc3f00493bf
SHA1
c670e553f678c50971acb5be9322f0d2fe0ea555
SHA256
a486943fd4ab610dc317ff71cb2b2de07282c3280dbd0ae0f8001780718a6a0e
SHA512

      
    
SHA1_git
9f83b2829fde692b0b3e36685a2d594962505f66
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
CloseWatcher.java | 3.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 * Iso8601: * Initial Developer: Robert Rathsack (firstName dot lastName at gmx dot de) */ package org.h2.util; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.ref.PhantomReference; import java.lang.ref.ReferenceQueue; import java.util.Collections; import java.util.HashSet; import java.util.Set; /** * A phantom reference to watch for unclosed objects. */ public class CloseWatcher extends PhantomReference<Object> { /** * The queue (might be set to null at any time). */ private static final ReferenceQueue<Object> queue = new ReferenceQueue<>(); /** * The reference set. Must keep it, otherwise the references are garbage * collected first and thus never enqueued. */ private static final Set<CloseWatcher> refs = Collections.synchronizedSet(new HashSet<>()); /** * The stack trace of when the object was created. It is converted to a * string early on to avoid classloader problems (a classloader can't be * garbage collected if there is a static reference to one of its classes). */ private String openStackTrace; /** * The closeable object. */ private AutoCloseable closeable; public CloseWatcher(Object referent, ReferenceQueue<Object> q, AutoCloseable closeable) { super(referent, q); this.closeable = closeable; } /** * Check for an collected object. * * @return the first watcher */ public static CloseWatcher pollUnclosed() { while (true) { CloseWatcher cw = (CloseWatcher) queue.poll(); if (cw == null) { return null; } if (refs != null) { refs.remove(cw); } if (cw.closeable != null) { return cw; } } } /** * Register an object. Before calling this method, pollUnclosed() should be * called in a loop to remove old references. * * @param o the object * @param closeable the object to close * @param stackTrace whether the stack trace should be registered (this is * relatively slow) * @return the close watcher */ public static CloseWatcher register(Object o, AutoCloseable closeable, boolean stackTrace) { CloseWatcher cw = new CloseWatcher(o, queue, closeable); if (stackTrace) { Exception e = new Exception("Open Stack Trace"); StringWriter s = new StringWriter(); e.printStackTrace(new PrintWriter(s)); cw.openStackTrace = s.toString(); } refs.add(cw); return cw; } /** * Unregister an object, so it is no longer tracked. * * @param w the reference */ public static void unregister(CloseWatcher w) { w.closeable = null; refs.remove(w); } /** * Get the open stack trace or null if none. * * @return the open stack trace */ public String getOpenStackTrace() { return openStackTrace; } public AutoCloseable getCloseable() { return closeable; } }
Detected license expression

      
    
Detected license expression (SPDX)

      
    
Percentage of license text
3.05
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 expression License clue details
(mpl-2.0 OR epl-1.0) AND proprietary-license {'score': 20.37, 'matcher': '3-seq', 'end_line': 3, 'rule_url': 'https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mpl-2.0_or_epl-1.0_and_proprietary-license_2.RULE', 'from_file': None, 'start_line': 2, 'matched_text': ' * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,\n * and the EPL 1.0 (https://h2database.com/html/license.html).', 'match_coverage': 20.37, 'matched_length': 11, 'rule_relevance': 100, 'rule_identifier': 'mpl-2.0_or_epl-1.0_and_proprietary-license_2.RULE', 'license_expression': '(mpl-2.0 OR epl-1.0) AND proprietary-license', 'license_expression_spdx': '(MPL-2.0 OR EPL-1.0) AND LicenseRef-scancode-proprietary-license'}
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