Produced by Araxis Merge on 10/18/2018 2:02:18 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\ImagingCacheImpl\main\src\java\gov\va\med\imaging\storage\cache\impl\jcifs | InstanceWritableByteChannelImpl.java | Thu Oct 11 13:30:20 2018 UTC |
2 | VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\ImagingCacheImpl\main\src\java\gov\va\med\imaging\storage\cache\impl\jcifs | InstanceWritableByteChannelImpl.java | Wed Oct 17 18:50:40 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 270 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | package go v.va.med.i maging.sto rage.cache .impl.jcif s; | |
2 | ||
3 | import jav a.io.IOExc eption; | |
4 | import jav a.io.Outpu tStream; | |
5 | import jav a.nio.Byte Buffer; | |
6 | import jav a.nio.chan nels.Chann els; | |
7 | import jav a.nio.chan nels.Writa bleByteCha nnel; | |
8 | import jav a.util.zip .Checksum; | |
9 | ||
10 | import gov .va.med.im aging.stor age.cache. InstanceWr itableByte Channel; | |
11 | import gov .va.med.im aging.stor age.cache. exceptions .Simultane ousWriteEx ception; | |
12 | import jci fs.smb.Smb File; | |
13 | ||
14 | /** | |
15 | * A class that simp ly wraps a FileChann el that wi ll be used for writi ng, | |
16 | * and rel eases a lo ck when th e channel is closed. | |
17 | * | |
18 | * @author PI I
|
|
19 | * | |
20 | */ | |
21 | class Inst anceWritab leByteChan nelImpl | |
22 | implements InstanceW ritableByt eChannel | |
23 | { | |
24 | /* * | |
25 | * | |
26 | * / | |
27 | pr ivate fina l JcifsByt eChannelFa ctory fact ory; | |
28 | pr ivate fina l SmbFile file; | |
29 | pr ivate fina l OutputSt ream outSt ream; | |
30 | pr ivate fina l Writable ByteChanne l wrappedC hannel; | |
31 | pr ivate long openedTim e = 0L; // keep this so th at we coul d close th e files ou rselves if the clien t does not | |
32 | pr ivate long lastAcces sedTime = 0L; | |
33 | pr ivate Chec ksum check sum; | |
34 | pr ivate Stac kTraceElem ent[] inst antiatingS tackTrace = null; | |
35 | ||
36 | In stanceWrit ableByteCh annelImpl( JcifsByteC hannelFact ory factor y, SmbFile file) | |
37 | th rows IOExc eption, Si multaneous WriteExcep tion | |
38 | { | |
39 | this (factory, file, null ); | |
40 | } | |
41 | ||
42 | In stanceWrit ableByteCh annelImpl( JcifsByteC hannelFact ory factor y, SmbFile file, Che cksum chec ksum) | |
43 | th rows IOExc eption, Si multaneous WriteExcep tion | |
44 | { | |
45 | this .factory = factory; | |
46 | this .file = fi le; | |
47 | this .checksum = checksum ; | |
48 | ||
49 | this .factory.l og.debug(" InstanceWr itableByte ChannelImp l, opening '" + file .getPath() + "'" ); | |
50 | if(t his.factor y.isTraceC hannelInst antiation( )) | |
51 | instan tiatingSta ckTrace = Thread.cur rentThread ().getStac kTrace(); | |
52 | outS tream = fi le.getOutp utStream() ; | |
53 | wrap pedChannel = Channel s.newChann el(outStre am); | |
54 | ||
55 | open edTime = S ystem.curr entTimeMil lis(); | |
56 | last AccessedTi me = opene dTime; | |
57 | } | |
58 | ||
59 | Sm bFile getF ile() | |
60 | { | |
61 | retu rn this.fi le; | |
62 | } | |
63 | ||
64 | St ackTraceEl ement[] ge tInstantia tingStackT race() | |
65 | { | |
66 | retu rn instant iatingStac kTrace; | |
67 | } | |
68 | ||
69 | pu blic long getLastAcc essedTime( ) | |
70 | { | |
71 | retu rn lastAcc essedTime; | |
72 | } | |
73 | ||
74 | pu blic Check sum getChe cksum() | |
75 | { | |
76 | retu rn this.ch ecksum; | |
77 | } | |
78 | ||
79 | /* * | |
80 | * Write fro m an NIO B yteBuffer to a strea m | |
81 | * / | |
82 | pu blic int w rite(ByteB uffer src) | |
83 | th rows IOExc eption | |
84 | { | |
85 | Chec ksum local ChecksumRe f = getChe cksum(); // just for perfor mance | |
86 | if(l ocalChecks umRef != n ull) | |
87 | for(By teBuffer l ocalBuffer = src.asR eadOnlyBuf fer(); loc alBuffer.h asRemainin g(); local ChecksumRe f.update(l ocalBuffer .get()) ); | |
88 | ||
89 | last AccessedTi me = Syste m.currentT imeMillis( ); | |
90 | ||
91 | retu rn wrapped Channel.wr ite(src); | |
92 | } | |
93 | ||
94 | pu blic void close() | |
95 | th rows IOExc eption | |
96 | { | |
97 | clos e(false); | |
98 | } | |
99 | ||
100 | /* (non-Java doc) | |
101 | * @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Insta nceWritabl eByteChann el#error() | |
102 | * / | |
103 | pu blic void error() | |
104 | th rows IOExc eption | |
105 | { | |
106 | clos e(true); | |
107 | } | |
108 | ||
109 | pr ivate void close(boo lean error Close) | |
110 | th rows IOExc eption | |
111 | { | |
112 | this .factory.l og.debug(" InstanceWr itableByte ChannelImp l, closing '" + file .getPath() + "' " + (errorClos e ? "WITH" : "withou t") + " de lete"); | |
113 | ||
114 | try{ wrappedCh annel.clos e(); } | |
115 | catc h(IOExcept ion e) | |
116 | {thi s.factory. log.warn(e );} // the channel m ay already be closed through s ome error or other t imeout, lo g it but k eep going | |
117 | ||
118 | try{ outStream .close(); } | |
119 | catc h(IOExcept ion e) | |
120 | {thi s.factory. log.warn(e );} | |
121 | ||
122 | if( errorClose ) | |
123 | this.f ile.delete (); | |
124 | ||
125 | // t he followi ng operati on really must occur regardles s of the | |
126 | // s uccess of the previo us IO oper ations, el se threads will lock and byte channels w ill repeat edly be cl osed when they are a lready clo sed | |
127 | this .factory.w ritableByt eChannelCl osed(this, errorClos e); | |
128 | ||
129 | this .factory.l og.debug(" InstanceWr itableByte ChannelImp l - '" + f ile.getPat h() + "' c losed " + (errorClos e ? "WITH" : "withou t") + " de lete"); | |
130 | } | |
131 | ||
132 | pu blic boole an isOpen( ) | |
133 | { | |
134 | retu rn wrapped Channel != null && w rappedChan nel.isOpen (); | |
135 | } | |
136 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.