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