Bug 152543 [DataBinding] ValueBinding NPE when update target from model is false
When a ValueBinding is constructed and instructed not to update the target from the model via the BindSpec a NPE is thrown when it tries to access the modelToTargetConverter. Exception in thread "main" java.lang.NullPointerException at org.eclipse.jface.internal.databinding.internal.ValueBinding.doUpdateTargetFromModel(ValueBinding.java:268) at org.eclipse.jface.internal.databinding.internal.ValueBinding.updateTargetFromModel(ValueBinding.java:250) at org.eclipse.jface.internal.databinding.internal.ValueBinding.<init>(ValueBinding.java:112) at Snippet.main(Snippet.java:32) Attaching patch...
bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValueBinding.java
model.addValueChangeListener(modelChangeListener);
		}
		if (bindSpec.isUpdateModel()) {
			targetToModelConverter = bindSpec.getTargetToModelConverter();
			if (targetToModelConverter == null) {
				throw new BindingException(
						"Missing target to model converter from " + target.getValueType() + " to " + model.getValueType()); 
			}
			if (!context.isAssignableFromTo(target.getValueType(),
					targetToModelConverter.getFromType())) {
				throw new BindingException(
						"target to model converter does not convert from target type. Expected: " + target.getValueType() + ", actual: " + targetToModelConverter.getFromType()); 
			}
			if (!context.isAssignableFromTo(targetToModelConverter.getToType(),
					model.getValueType())) {
				throw new BindingException(
						"target to model converter does convert to model type. Expected: " + model.getValueType() + ", actual: " + targetToModelConverter.getToType()); 
			}
			targetValidator = bindSpec.getTypeConversionValidator();
			if (targetValidator == null) {
				throw new BindingException("Missing validator"); 
			}
			domainValidator = bindSpec.getDomainValidator();
			target.addValueChangeListener(targetChangeListener);
			if (target instanceof IVetoableValue) {
				((IVetoableValue) target)
						.addValueChangingListener(targetChangingListener);
			}
		}
		updateTargetFromModel();