[rfc][icedtea-web] MD5SumWatcher util

Andrew Azores aazores at redhat.com
Mon Mar 10 18:58:26 UTC 2014


On 03/10/2014 02:46 PM, Omair Majid wrote:
> * Andrew Azores <aazores at redhat.com> [2014-03-10 14:29]:
>> This adds a small utility class that makes it easy to check when a
>> file's contents on disk have been changed. This needs to be custom
>> built here because we don't have access to nio2 yet, and pulling in
>> an Apache lib dependency just for this is overkill.
> Nice patch!
>
>> +++ b/netx/net/sourceforge/jnlp/util/MD5SumWatcher.java
>> +    public int updateWithDialog(final JFrame parent) throws FileNotFoundException, IOException {
>> +        final boolean changed = update();
>> +        if (changed) {
>> +            return showFileChangeWhileLoadedDialog(parent, watchedFile.getCanonicalPath());
>> +        }
>> +        return JOptionPane.NO_OPTION;
>> +    }
>> +    private static int showFileChangeWhileLoadedDialog(final JFrame frame, final String filePath) {
>> +        return JOptionPane.showConfirmDialog(frame, R("RFileModifiedWhileLoadedDetail", filePath),
>> +                R("RFileModifiedWhileLoaded"), JOptionPane.YES_NO_CANCEL_OPTION);
>> +    }
> Unless there is a strong reason to, I would recommend keeping GUI out of
> this class.

Fair enough. I'll move it all into the PolicyEditor patch to come then.

>
>> +++ b/tests/netx/unit/net/sourceforge/jnlp/util/MD5SumWatcherTest.java
> Nice tests!
>
>> +    @Before
>> +    public void createNewFile() throws Exception {
>> +        file = File.createTempFile("md5sumwatchertest", "tmp");
>> +        file.deleteOnExit();
> Personally, I would have removed the file in an @After block. That way,
> the file is removed after each test, not just on VM exit.
>
> Thanks,
> Omair
>

Sounds reasonable to me.

Thanks,

-- 
Andrew A

-------------- next part --------------
A non-text attachment was scrubbed...
Name: md5sumwatcher2.patch
Type: text/x-patch
Size: 10028 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20140310/b76095b5/md5sumwatcher2.patch>


More information about the distro-pkg-dev mailing list