4893524: Swing drop targets should call close() on transferred readers and streams
Reviewed-by: serb, tr, aivanov
This commit is contained in:
parent
3c920f9cc6
commit
58906bf8fb
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -2598,18 +2598,21 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
|||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
ic.endComposition();
|
ic.endComposition();
|
||||||
}
|
}
|
||||||
Reader r = importFlavor.getReaderForText(t);
|
|
||||||
|
|
||||||
if (modeBetween) {
|
// Use try-with-resource logic to close stream after use
|
||||||
Caret caret = c.getCaret();
|
try (Reader r = importFlavor.getReaderForText(t)) {
|
||||||
if (caret instanceof DefaultCaret) {
|
|
||||||
((DefaultCaret)caret).setDot(pos, dropBias);
|
if (modeBetween) {
|
||||||
} else {
|
Caret caret = c.getCaret();
|
||||||
c.setCaretPosition(pos);
|
if (caret instanceof DefaultCaret) {
|
||||||
|
((DefaultCaret) caret).setDot(pos, dropBias);
|
||||||
|
} else {
|
||||||
|
c.setCaretPosition(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
handleReaderImport(r, c, useRead);
|
handleReaderImport(r, c, useRead);
|
||||||
|
}
|
||||||
|
|
||||||
if (isDrop) {
|
if (isDrop) {
|
||||||
c.requestFocus();
|
c.requestFocus();
|
||||||
|
Loading…
Reference in New Issue
Block a user