use of java.text.ParseException in project buck by facebook.
the class AppleSdkDiscovery method buildSdkFromPath.
private static boolean buildSdkFromPath(Path sdkDir, AppleSdk.Builder sdkBuilder, ImmutableMap<String, AppleToolchain> xcodeToolchains, Optional<AppleToolchain> defaultToolchain, AppleConfig appleConfig) throws IOException {
try (InputStream sdkSettingsPlist = Files.newInputStream(sdkDir.resolve("SDKSettings.plist"));
BufferedInputStream bufferedSdkSettingsPlist = new BufferedInputStream(sdkSettingsPlist)) {
NSDictionary sdkSettings;
try {
sdkSettings = (NSDictionary) PropertyListParser.parse(bufferedSdkSettingsPlist);
} catch (PropertyListFormatException | ParseException | SAXException e) {
LOG.error(e, "Malformatted SDKSettings.plist. Skipping SDK path %s.", sdkDir);
return false;
} catch (ParserConfigurationException e) {
throw new IOException(e);
}
String name = sdkSettings.objectForKey("CanonicalName").toString();
String version = sdkSettings.objectForKey("Version").toString();
NSDictionary defaultProperties = (NSDictionary) sdkSettings.objectForKey("DefaultProperties");
Optional<ImmutableList<String>> toolchains = appleConfig.getToolchainsOverrideForSDKName(name);
boolean foundToolchain = false;
if (!toolchains.isPresent()) {
NSArray settingsToolchains = (NSArray) sdkSettings.objectForKey("Toolchains");
if (settingsToolchains != null) {
toolchains = Optional.of(Arrays.stream(settingsToolchains.getArray()).map(Object::toString).collect(MoreCollectors.toImmutableList()));
}
}
if (toolchains.isPresent()) {
for (String toolchainId : toolchains.get()) {
AppleToolchain toolchain = xcodeToolchains.get(toolchainId);
if (toolchain != null) {
foundToolchain = true;
sdkBuilder.addToolchains(toolchain);
} else {
LOG.debug("Specified toolchain %s not found for SDK path %s", toolchainId, sdkDir);
}
}
}
if (!foundToolchain && defaultToolchain.isPresent()) {
foundToolchain = true;
sdkBuilder.addToolchains(defaultToolchain.get());
}
if (!foundToolchain) {
LOG.warn("No toolchains found and no default toolchain. Skipping SDK path %s.", sdkDir);
return false;
} else {
NSString platformName = (NSString) defaultProperties.objectForKey("PLATFORM_NAME");
ApplePlatform applePlatform = ApplePlatform.of(platformName.toString());
sdkBuilder.setName(name).setVersion(version).setApplePlatform(applePlatform);
ImmutableList<String> architectures = validArchitecturesForPlatform(applePlatform, sdkDir);
sdkBuilder.addAllArchitectures(architectures);
return true;
}
} catch (NoSuchFileException e) {
LOG.warn(e, "Skipping SDK at path %s, no SDKSettings.plist found", sdkDir);
return false;
}
}
use of java.text.ParseException in project buck by facebook.
the class AppleToolchainDiscovery method toolchainFromPlist.
private static Optional<AppleToolchain> toolchainFromPlist(Path toolchainDir, String plistName) throws IOException {
Path toolchainInfoPlistPath = toolchainDir.resolve(plistName);
InputStream toolchainInfoPlist = Files.newInputStream(toolchainInfoPlistPath);
BufferedInputStream bufferedToolchainInfoPlist = new BufferedInputStream(toolchainInfoPlist);
NSDictionary parsedToolchainInfoPlist;
try {
parsedToolchainInfoPlist = (NSDictionary) PropertyListParser.parse(bufferedToolchainInfoPlist);
} catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) {
LOG.error(e, "Failed to parse %s: %s, ignoring", plistName, toolchainInfoPlistPath);
return Optional.empty();
}
NSObject identifierObject = parsedToolchainInfoPlist.objectForKey("Identifier");
if (identifierObject == null) {
LOG.error("Identifier not found for toolchain path %s, ignoring", toolchainDir);
return Optional.empty();
}
String identifier = identifierObject.toString();
NSObject versionObject = parsedToolchainInfoPlist.objectForKey("DTSDKBuild");
Optional<String> version = versionObject == null ? Optional.empty() : Optional.of(versionObject.toString());
LOG.debug("Mapped SDK identifier %s to path %s", identifier, toolchainDir);
AppleToolchain.Builder toolchainBuilder = AppleToolchain.builder();
toolchainBuilder.setIdentifier(identifier);
toolchainBuilder.setVersion(version);
toolchainBuilder.setPath(toolchainDir);
return Optional.of(toolchainBuilder.build());
}
use of java.text.ParseException in project elasticsearch by elastic.
the class ShardUpgradeResult method readFrom.
@Override
public void readFrom(StreamInput in) throws IOException {
shardId = ShardId.readShardId(in);
primary = in.readBoolean();
upgradeVersion = Version.readVersion(in);
try {
oldestLuceneSegment = org.apache.lucene.util.Version.parse(in.readString());
} catch (ParseException ex) {
throw new IOException("failed to parse lucene version [" + oldestLuceneSegment + "]", ex);
}
}
use of java.text.ParseException in project elasticsearch by elastic.
the class ExpressionTests method testLinkError.
public void testLinkError() {
ScriptException e = expectThrows(ScriptException.class, () -> {
compile("doc['e'].value * 5");
});
assertTrue(e.getCause() instanceof ParseException);
}
use of java.text.ParseException in project elasticsearch by elastic.
the class ExpressionTests method testCompileError.
public void testCompileError() {
ScriptException e = expectThrows(ScriptException.class, () -> {
compile("doc['d'].value * *@#)(@$*@#$ + 4");
});
assertTrue(e.getCause() instanceof ParseException);
}
Aggregations