SF3065265 Bit masking in Variant.getXXXRef() uses wrong mask allowing more than one type to be seen as the requested type. Code that passed in the correct type always worked but invalid types were not always detected.
This commit is contained in:
@@ -648,6 +648,7 @@ public class VariantTest extends BaseTestCase {
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
for (int variantIndex = 0; variantIndex < initialRunSize; variantIndex++) {
|
||||
try {
|
||||
@@ -664,4 +665,40 @@ public class VariantTest extends BaseTestCase {
|
||||
isComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* there was a bitwise masking error that let booleans be seen as dispatch
|
||||
* objects Bug Report SF3065265
|
||||
*/
|
||||
public void testGetDispatch() {
|
||||
Variant testVariant = new Variant();
|
||||
testVariant.putBooleanRef(true);
|
||||
try {
|
||||
// throws IllegalStateException if Jacob detects the type
|
||||
// throws some other bad exception if COM blows up failing the
|
||||
// conversion
|
||||
testVariant.getDispatchRef();
|
||||
fail("Should not have converted boolean to dispatch");
|
||||
} catch (IllegalStateException e) {
|
||||
// yeah! can't get dispatch from boolean
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* there was a bitwise masking error that let booleans be seen as dispatch
|
||||
* objects Bug Report SF3065265
|
||||
*/
|
||||
public void testGetError() {
|
||||
Variant testVariant = new Variant();
|
||||
testVariant.putErrorRef(3);
|
||||
try {
|
||||
// throws IllegalStateException if Jacob detects the type
|
||||
// throws some other bad exception if COM blows up failing the
|
||||
// conversion
|
||||
testVariant.getStringRef();
|
||||
fail("Should not have converted error to string");
|
||||
} catch (IllegalStateException e) {
|
||||
// yeah! can't get dispatch from boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user