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 | InstanceReadableByteChannelImpl.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 | InstanceReadableByteChannelImpl.java | Wed Oct 17 18:50:32 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 292 |
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.File; | |
4 | import jav a.io.IOExc eption; | |
5 | import jav a.io.Input Stream; | |
6 | import jav a.nio.Byte Buffer; | |
7 | import jav a.nio.chan nels.Chann els; | |
8 | import jav a.nio.chan nels.Reada bleByteCha nnel; | |
9 | import jav a.util.zip .Checksum; | |
10 | ||
11 | import gov .va.med.im aging.stor age.cache. InstanceRe adableByte Channel; | |
12 | import gov .va.med.im aging.stor age.cache. exceptions .InstanceU navailable Exception; | |
13 | import jci fs.smb.Smb File; | |
14 | ||
15 | /** | |
16 | * A class that simp ly wraps a FileChann el that wi ll be used for readi ng, | |
17 | * and rel eases a lo ck when th e channel is closed. | |
18 | * | |
19 | * @author PI I
|
|
20 | * | |
21 | */ | |
22 | public cla ss Instanc eReadableB yteChannel Impl | |
23 | implements InstanceR eadableByt eChannel | |
24 | { | |
25 | /* * | |
26 | * | |
27 | * / | |
28 | pr ivate fina l JcifsByt eChannelFa ctory fact ory; | |
29 | pr ivate fina l SmbFile file; | |
30 | pr ivate fina l Readable ByteChanne l wrappedC hannel; | |
31 | pr ivate fina l InputStr eam inStre am; | |
32 | 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 | |
33 | pr ivate long lastAcces sedTime = 0L; | |
34 | pr ivate Chec ksum check sum; | |
35 | pr ivate Stac kTraceElem ent[] inst antiatingS tackTrace = null; | |
36 | ||
37 | In stanceRead ableByteCh annelImpl( JcifsByteC hannelFact ory factor y, SmbFile file) | |
38 | th rows IOExc eption, In stanceUnav ailableExc eption | |
39 | { | |
40 | this (factory, file, null ); | |
41 | } | |
42 | ||
43 | In stanceRead ableByteCh annelImpl( JcifsByteC hannelFact ory factor y, SmbFile file, Che cksum chec ksum) | |
44 | th rows IOExc eption, In stanceUnav ailableExc eption | |
45 | { | |
46 | this .factory = factory; | |
47 | this .file = fi le; | |
48 | ||
49 | this .factory.l og.debug(" InstanceRe adableByte ChannelImp l, opening '" + file .getPath() + "'" ); | |
50 | // t race the c hannel ins tantiation so we can tattle-ta le later i f its not closed | |
51 | if(t his.factor y.isTraceC hannelInst antiation( )) | |
52 | instan tiatingSta ckTrace = Thread.cur rentThread ().getStac kTrace(); | |
53 | ||
54 | inSt ream = fil e.getInput Stream(); | |
55 | wrap pedChannel = Channel s.newChann el(inStrea m); | |
56 | ||
57 | open edTime = S ystem.curr entTimeMil lis(); | |
58 | last AccessedTi me = opene dTime; | |
59 | ||
60 | // t ry to acqu ire a shar ed lock on the file | |
61 | //lo ck = wrapp edChannel. tryLock(0L , Long.MAX _VALUE, tr ue); | |
62 | } | |
63 | ||
64 | Sm bFile getF ile() | |
65 | { | |
66 | retu rn this.fi le; | |
67 | } | |
68 | ||
69 | St ackTraceEl ement[] ge tInstantia tingStackT race() | |
70 | { | |
71 | retu rn instant iatingStac kTrace; | |
72 | } | |
73 | ||
74 | pu blic java. util.zip.C hecksum ge tChecksum( ) | |
75 | { | |
76 | retu rn this.ch ecksum; | |
77 | } | |
78 | ||
79 | /* (non-Java doc) | |
80 | * @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Insta nceReadabl eByteChann el#error() | |
81 | * / | |
82 | pu blic void error() | |
83 | th rows IOExc eption | |
84 | { | |
85 | clos e(true); | |
86 | } | |
87 | ||
88 | /* * | |
89 | * A normal close, the cache ite m contents are valid . | |
90 | * / | |
91 | pu blic void close() | |
92 | th rows IOExc eption | |
93 | { | |
94 | clos e(false); | |
95 | } | |
96 | ||
97 | pr ivate void close(boo lean error Close) | |
98 | th rows IOExc eption | |
99 | { | |
100 | this .factory.l og.debug(" InstanceRe adableByte ChannelImp l, closing '" + file .getPath() + "' " + (errorClos e ? "WITH" : "withou t") + " de lete"); | |
101 | ||
102 | try{ wrappedCh annel.clos e(); } | |
103 | catc h(IOExcept ion e) | |
104 | {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 | |
105 | ||
106 | try{ inStream. close(); } | |
107 | catc h(IOExcept ion e) | |
108 | {thi s.factory. log.warn(e );} // the stream ma y already be closed through so me error o r other ti meout, log it but ke ep going | |
109 | ||
110 | if( errorClose ) | |
111 | this.f ile.delete (); | |
112 | ||
113 | // t he followi ng two ope rations re ally must occur rega rdless of the | |
114 | // s uccess of the previo us IO oper ations, el se channel s will rep eatedly be closed wh en they ar e already closed | |
115 | fact ory.readab leByteChan nelClosed( this, erro rClose); | |
116 | ||
117 | this .factory.l og.debug(" InstanceRe adableByte ChannelImp l - '" + f ile.getPat h() + "' c losed " + (errorClos e ? "WITH" : "withou t") + " de lete"); | |
118 | } | |
119 | ||
120 | ||
121 | pu blic boole an isOpen( ) | |
122 | { | |
123 | retu rn wrapped Channel != null && w rappedChan nel.isOpen (); | |
124 | } | |
125 | ||
126 | pu blic int r ead(ByteBu ffer dst) | |
127 | th rows IOExc eption | |
128 | { | |
129 | Chec ksum local ChecksumRe f = getChe cksum(); // just for perfor mance | |
130 | if(l ocalChecks umRef != n ull) | |
131 | for(By teBuffer l ocalBuffer = dst.asR eadOnlyBuf fer(); loc alBuffer.h asRemainin g(); local ChecksumRe f.update(l ocalBuffer .get()) ); | |
132 | ||
133 | last AccessedTi me = Syste m.currentT imeMillis( ); | |
134 | retu rn wrapped Channel.re ad(dst); | |
135 | } | |
136 | ||
137 | pu blic long getLastAcc essedTime( ) | |
138 | { | |
139 | retu rn lastAcc essedTime; | |
140 | } | |
141 | ||
142 | @O verride | |
143 | pu blic File getCacheFi le() { | |
144 | // T ODO Auto-g enerated m ethod stub | |
145 | retu rn null; | |
146 | } | |
147 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.